public async Task <bool> DeleteBusinessDocumentAttachment(BusinessDocumentAttachmentDto input) { try { var businessDocumentAttachment = ObjectMapper.Map <BusinessDocumentAttachment>(input); await _businessDocumentAttachmentRepository.DeleteAsync(input.Id); return(true); } catch (Exception ex) { throw ex; } }
public async Task <AjaxResponse> Delete([FromBody] DeleteVModel model) { var businessDocumentAttachmentDto = new BusinessDocumentAttachmentDto() { Id = model.AttachmentId, BusinessEntityId = model.BusinessEntityId, BusinessDocumentId = model.BusinessDocumentId }; var result = await _documentAppService.DeleteBusinessDocumentAttachment(businessDocumentAttachmentDto); return(new AjaxResponse() { Success = result }); }
public async Task <BusinessDocumentAttachmentDto> CreateBusinessDocumentAttachment(BusinessDocumentAttachmentDto input) { try { var businessDocumentAttachment = ObjectMapper.Map <BusinessDocumentAttachment>(input); input.Id = await _businessDocumentAttachmentRepository.InsertAndGetIdAsync(businessDocumentAttachment); return(input); } catch (Exception ex) { throw ex; } }
public async Task <AjaxResponse> Upload(UploadVModel model) { if (ModelState.IsValid) { string profilePhotoPath = string.Empty; string fileUrl = UploadedFile(model, out profilePhotoPath); if (!string.IsNullOrEmpty(fileUrl)) { //Delete Old if (model.IsDeleteOld) { var oldAttachmentList = (await _documentAppService.GetAllBusinessDocumentAttachments(null, model.BusinessDocumentId, model.BusinessEntityId)).Items; foreach (var oldAttachment in oldAttachmentList) { await _documentAppService.DeleteBusinessDocumentAttachment(new BusinessDocumentAttachmentDto() { Id = oldAttachment.Id }); } } var businessDocumentAttachmentDto = new BusinessDocumentAttachmentDto() { BusinessDocumentId = model.BusinessDocumentId, BusinessEntityId = model.BusinessEntityId, FilePath = fileUrl, FileName = System.IO.Path.GetFileNameWithoutExtension(model.Image.FileName), FileExt = System.IO.Path.GetExtension(model.Image.FileName), Order = 0 }; var attachment = await _documentAppService.CreateBusinessDocumentAttachment(businessDocumentAttachmentDto); if (attachment.Id > 0) { if (!string.IsNullOrEmpty(profilePhotoPath))//Profile Photo { ChangeProfilePhotoDto changeProfilePhotoDto = new ChangeProfilePhotoDto() { Id = model.BusinessEntityId, ProfilePhotoPath = businessDocumentAttachmentDto.Id.ToString() }; await _userAppService.UpdateProfilePhoto(changeProfilePhotoDto); } return(new AjaxResponse() { Success = true, Result = attachment }); } else { return(new AjaxResponse(new ErrorInfo() { Message = "AttachmentNotAdded" })); } } } return(new AjaxResponse(new ErrorInfo() { Message = "Errors" })); }