public async Task <ActionResult <AttachmentDto> > Put([FromBody] AttachmentEditDto value) { if (value.Id == Guid.Empty) { throw new Exception("Unable to edit a Attachment without ID"); } var res = await _service.Save(value); return(res); }
/// <summary> /// 编辑Attachment /// </summary> protected virtual async Task UpdateAttachmentAsync(AttachmentEditDto input) { //TODO:更新前的逻辑判断,是否允许更新 var entity = await _attachmentRepository.GetAsync(input.Id.Value); input.MapTo(entity); // ObjectMapper.Map(input, entity); await _attachmentRepository.UpdateAsync(entity); }
public static Attachment ToEntity(this AttachmentEditDto e) { if (e == null) { return(null); } var res = new Attachment(); res.Id = e.Id; res.Name = e.Name; res.IdResource = e.IdResource; res.FullPath = e.FullPath; res.Size = e.Size; return(res); }
/// <summary> /// 新增Attachment /// </summary> protected virtual async Task <AttachmentEditDto> CreateAttachmentAsync(AttachmentEditDto input) { var plan = await _planRepository.GetAsync(input.PlanId); if (plan == null) { throw new EntityNotFoundException(); } var entity = ObjectMapper.Map <Attachment>(input); entity = await _attachmentRepository.InsertAsync(entity); plan.Attachments.Add(entity); return(entity.MapTo <AttachmentEditDto>()); }
/// <summary> /// 导出Attachment为excel表 /// </summary> /// <returns></returns> //public async Task<FileDto> GetAttachmentsToExcel(){ //var users = await UserManager.Users.ToListAsync(); //var userListDtos = ObjectMapper.Map<List<UserListDto>>(users); //await FillRoleNames(userListDtos); //return _userListExcelExporter.ExportToFile(userListDtos); //} /// <summary> /// MPA版本才会用到的方法 /// </summary> /// <param name="input"></param> /// <returns></returns> public async Task <GetAttachmentForEditOutput> GetAttachmentForEdit(NullableIdDto <int> input) { var output = new GetAttachmentForEditOutput(); AttachmentEditDto attachmentEditDto; if (input.Id.HasValue) { var entity = await _attachmentRepository.GetAsync(input.Id.Value); attachmentEditDto = entity.MapTo <AttachmentEditDto>(); //attachmentEditDto = ObjectMapper.Map<List <attachmentEditDto>>(entity); } else { attachmentEditDto = new AttachmentEditDto(); } output.Attachment = attachmentEditDto; return(output); }
public void Download(AttachmentEditDto input) { throw new NotImplementedException(); }
public void Save(AttachmentEditDto input) { var item = new Attachment(); this._attachmentRepository.Insert(input.MapTo(item)); }
public async Task <ActionResult <AttachmentDto> > Post([FromBody] AttachmentEditDto value) { var res = await _service.Save(value); return(res); }
public Task <AttachmentDto> Save(AttachmentEditDto filter) { throw new NotImplementedException(); }