/// <summary> /// list多项目添加 /// </summary> /// <param name="cameraDtos"></param> /// <returns></returns> public async Task <PagedResultDto <CameraDto> > PostInsertList(List <UpdateCameraDto> cameraDtos) { if (cameraDtos == null) { return(null); } List <Camera> cameras = new List <Camera>(); var data = ObjectMapper.Map <List <UpdateCameraDto>, List <Camera> >(cameraDtos); //简繁转换 string simplifieddata = Newtonsoft.Json.JsonConvert.SerializeObject(data); string traditionaldata = ChineseConverter.Convert(simplifieddata, ChineseConversionDirection.SimplifiedToTraditional); var data2 = Newtonsoft.Json.JsonConvert.DeserializeObject <List <Camera> >(traditionaldata); var cameradata = await _repository.GetListAsync(); foreach (var item in data2) { var cameralist = cameradata.Where(u => u.Camera_ID == item.Camera_ID); if (cameralist.Count() == 0) { var camera = _repository.InsertAsync(item); cameras.Add(camera.Result); } else { foreach (var tem in cameralist) { await _repository.DeleteAsync(tem); } var camera = _repository.InsertAsync(item); cameras.Add(camera.Result); } } var camerasdto = ObjectMapper.Map <List <Camera>, List <CameraDto> >(cameras); return(new PagedResultDto <CameraDto> { TotalCount = camerasdto.Count, Items = camerasdto }); }
public async Task DeleteCameraAsync(int cameraId) { await _cameraRepository.DeleteAsync(cameraId); }