using AutoMapper; using Ropin.Inspection.Common.Accessor.Interface; using Ropin.Inspection.Model; using Ropin.Inspection.Model.Entities; using Ropin.Inspection.Model.ViewModel.DEV; using Ropin.Inspection.Repository; using Ropin.Inspection.Repository.DEV.Interface; using Ropin.Inspection.Service.DEV.Interface; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace Ropin.Inspection.Service.DEV { public class dev_DevBoxMigrateService : Idev_DevBoxMigrateService { private readonly Idev_DevBoxMigrateRepository _repository; private readonly IMapper _mapper; private readonly IClaimsAccessor _claims; private readonly InspectionDbContext _sqlDBContext; private readonly ITdevBoxRepository _tdevBoxRepository; public dev_DevBoxMigrateService(IClaimsAccessor claims, InspectionDbContext sqlDBContext, Idev_DevBoxMigrateRepository repository, IMapper mapper, ITdevBoxRepository tdevBoxRepository) { _repository = repository; _mapper = mapper; _claims = claims; _sqlDBContext = sqlDBContext; _tdevBoxRepository= tdevBoxRepository; } public async Task CreateOneAsync(dev_DevBoxMigrateModel viewModel) { viewModel.C_ID = Guid.NewGuid().ToString(); var content = _mapper.Map(viewModel); var devStore = await _tdevBoxRepository.GetByIdAsync(viewModel.C_DevBoxCode); if (devStore == null) { throw new Exception("创建失败,没有找到要移机的盒子"); } devStore.C_StoreCode = viewModel.C_CurrentStoreCode; _tdevBoxRepository.Update(devStore); //content.C_ID = id; content.C_CreateBy = _claims.ApiUserId; content.D_CreateOn = DateTime.Now; _repository.Create(content); var result = await _repository.SaveAsync(); if (!result) { throw new Exception("创建失败"); } } public async Task> GetConditionAsync(dev_DevBoxMigrateSearchModel searchModel) { var dtoList = await _repository.GetConditionAsync(searchModel); return dtoList; } public Task DeleteAsync(string id) { throw new NotImplementedException(); } public Task GetByIdAsync(string id) { throw new NotImplementedException(); } public Task IsExistAsync(string id) { throw new NotImplementedException(); } public Task UpdateOneAsync(dev_DevBoxMigrateModel viewModel, params string[] fields) { throw new NotImplementedException(); } } }