123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115 |
- using AutoMapper;
- using Ropin.Inspection.Common.Accessor.Interface;
- using Ropin.Inspection.Model.Entities;
- using Ropin.Inspection.Model.SearchModel;
- using Ropin.Inspection.Model.ViewModel;
- using Ropin.Inspection.Repository.Interface;
- using Ropin.Inspection.Service.Interface;
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Linq.Expressions;
- using System.Text;
- using System.Threading.Tasks;
- namespace Ropin.Inspection.Service
- {
- public class TispSpotRegionService : ITispSpotRegionService
- {
- private readonly ITispSpotRegionRepository _repository;
- private readonly IMapper _mapper;
- private readonly IClaimsAccessor _claims;
- public TispSpotRegionService(IClaimsAccessor claims, ITispSpotRegionRepository repository, IMapper mapper)
- {
- _repository = repository;
- _mapper = mapper;
- _claims = claims;
- }
- public Task CreateOneAsync(TispSpotsRegionViewModel viewModel)
- {
- throw new NotImplementedException();
- }
- public async Task CreateSpotsRegionsAsync(TispSpotRegionCreateViewModel viewModel)
- {
- foreach (Guid RegionId in viewModel.RegionIdList)
- {
- await _repository.DeleteByRegionIdAsync(RegionId);
- foreach (Guid spotId in viewModel.SpotIdList)
- {
- TISP_SpotRegion spotRegion = new TISP_SpotRegion()
- {
- C_SpotCode = spotId,
- C_RegionCode = RegionId,
- C_CreateBy = _claims.ApiUserId,
- D_CreateOn = DateTime.Now,
- C_LastUpdatedBy = _claims.ApiUserId,
- D_LastUpdatedOn = DateTime.Now,
- C_Status = '1',
- };
- _repository.Create(spotRegion);
- }
- }
- var result = await _repository.SaveAsync();
- if (!result)
- {
- throw new Exception("创建失败");
- }
- }
- public async Task DeleteAsync(Guid id)
- {
- var content = await _repository.GetByIdAsync(id);
- if (content == null)
- {
- throw new Exception("没有此巡检路径");
- }
- _repository.Delete(content);
- var result = await _repository.SaveAsync();
- if (!result)
- {
- throw new Exception("删除失败");
- }
- }
- public Task<IEnumerable<TispSpotsRegionViewModel>> GetByConditionAsync(Expression<Func<TispSpotsRegionViewModel, bool>> expression)
- {
- throw new NotImplementedException();
- }
- public Task<TispSpotsRegionViewModel> GetByIdAsync(Guid id)
- {
- throw new NotImplementedException();
- }
- public async Task<IEnumerable<TispSpotsRegionViewModel>> GetSpotRegionsAsyncByPage(TispSpotRegionSearchModel searchViewModel)
- {
- var pagedList = await _repository.GetSpotRegionsAsyncByPage(searchViewModel);
- searchViewModel.TotalCount = pagedList == null ? 0 : pagedList.Totals;
- return pagedList?.Rows;
- }
- public async Task<IEnumerable<TispSpotsRegionViewModel>> GetSpotsRegionAsyncByPage(TispSpotRegionSearchModel searchViewModel)
- {
- var pagedList = await _repository.GetSpotsRegionAsyncByPage(searchViewModel);
- searchViewModel.TotalCount = pagedList == null ? 0 : pagedList.Totals;
- return pagedList?.Rows;
- }
- public Task<bool> IsExistAsync(Guid id)
- {
- throw new NotImplementedException();
- }
- public Task UpdateAsync(Guid id, TispContentUpdateViewModel updateModel)
- {
- throw new NotImplementedException();
- }
- public Task<int> UpdateOneAsync(TispSpotsRegionViewModel viewModel, params string[] fields)
- {
- throw new NotImplementedException();
- }
- }
- }
|