123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114 |
- 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 TispSpotRouteService : ITispSpotRouteService
- {
- private readonly ITispSpotRouteRepository _repository;
- private readonly IMapper _mapper;
- private readonly IClaimsAccessor _claims;
- public TispSpotRouteService(IClaimsAccessor claims, ITispSpotRouteRepository repository, IMapper mapper)
- {
- _repository = repository;
- _mapper = mapper;
- _claims = claims;
- }
- public Task CreateOneAsync(TispSpotsRouteViewModel viewModel)
- {
- throw new NotImplementedException();
- }
- public async Task CreateSpotsRoutesAsync(TispSpotRouteCreateViewModel viewModel)
- {
- foreach (Guid routeId in viewModel.routeIdList)
- {
- await _repository.DeleteByRouteIdAsync(routeId);
- foreach (Guid spotId in viewModel.spotIdList)
- {
- TISP_SpotRoute spotRoute = new TISP_SpotRoute()
- {
- C_SpotCode = spotId,
- C_RouteCode = routeId,
- C_CreateBy = _claims.ApiUserId,
- D_CreateOn = DateTime.Now,
- C_LastUpdatedBy = _claims.ApiUserId,
- D_LastUpdatedOn = DateTime.Now,
- C_Status = '1',
- };
- _repository.Create(spotRoute);
- }
- }
- 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<TispSpotsRouteViewModel>> GetByConditionAsync(Expression<Func<TispSpotsRouteViewModel, bool>> expression)
- {
- throw new NotImplementedException();
- }
- public Task<TispSpotsRouteViewModel> GetByIdAsync(Guid id)
- {
- throw new NotImplementedException();
- }
- public async Task<IEnumerable<TispSpotsRouteViewModel>> GetSpotRoutesAsyncByPage(TispSpotRouteSearchModel searchViewModel)
- {
- var pagedList = await _repository.GetSpotRoutesAsyncByPage(searchViewModel);
- searchViewModel.TotalCount = pagedList==null? 0:pagedList.Totals;
- return pagedList?.Rows;
- }
- public async Task<IEnumerable<TispSpotsRouteViewModel>> GetSpotsRouteAsyncByPage(TispSpotRouteSearchModel searchViewModel)
- {
- var pagedList = await _repository.GetSpotsRouteAsyncByPage(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(TispSpotsRouteViewModel viewModel, params string[] fields)
- {
- throw new NotImplementedException();
- }
- }
- }
|