12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394 |
- using AutoMapper;
- using Ropin.Inspection.Common.Accessor.Interface;
- using Ropin.Inspection.Model.Entities;
- 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.Text;
- using System.Threading.Tasks;
- namespace Ropin.Inspection.Service
- {
- public class TispContentGroupItemService : ITispContentGroupItemService
- {
- private readonly ITispContentGroupItemRepository _repository;
- private readonly IMapper _mapper;
- private readonly IClaimsAccessor _claims;
- public TispContentGroupItemService(IClaimsAccessor claims, ITispContentGroupItemRepository repository, IMapper mapper)
- {
- _repository = repository;
- _mapper = mapper;
- _claims = claims;
- }
- public async Task CreateContentGroupItemsAsync(IEnumerable<TispContentGroupItemCreateViewModel> items)
- {
-
- foreach (var item in items)
- {
- await _repository.DeleteByGroupIdAsync(item.G_ContentGroupCode);
- _repository.Create(new TISP_ContentGroupItem { G_ContentGroupCode = item.G_ContentGroupCode,G_ContentCode = item.G_ContentCode });
- }
- var result = await _repository.SaveAsync();
- if (!result)
- {
- throw new Exception("创建失败");
- }
- }
- public async Task<IEnumerable<TispContentGroupItemViewModel>> GetContentGroupItemByGroupIdAsync(Guid groupId)
- {
- return await _repository.GetContentGroupItemByGroupIdAsync(groupId);
- }
- public async Task CreateOneAsync(TispContentGroupItemViewModel viewModel)
- {
- var content = _mapper.Map<TISP_ContentGroupItem>(viewModel);
- //content.G_CreateBy = _claims.ApiUserId;
- //content.D_CreateOn = DateTime.Now;
- //content.C_Status = "1";
- _repository.Create(content);
- 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<TispContentGroupItemViewModel>> GetAllAsync()
- {
- throw new NotImplementedException();
- }
- public Task<TispContentGroupItemViewModel> GetByIdAsync(Guid id)
- {
- throw new NotImplementedException();
- }
- public Task<bool> IsExistAsync(Guid id)
- {
- throw new NotImplementedException();
- }
- public Task<int> UpdateOneAsync(TispContentGroupItemViewModel viewModel, params string[] fields)
- {
- throw new NotImplementedException();
- }
- }
- }
|