public async Task <Response <AttachmentDoc> > UploadDoc(AttachmentDoc model) { try { AttachmentHeader header = new AttachmentHeader(); header = model.AttachmentHeaderItem; header.Is_Active = true; _context.AttachmentHeader.Add(header); await _context.SaveChangesAsync(); AttachmentDetails details = new AttachmentDetails(); details = model.AttachmentDetailsItem; details.Is_Active = true; details.Attachment_Header_ID = header.Attachment_Header_ID; _context.AttachmentDetails.Add(details); await _context.SaveChangesAsync(); return(new Response <AttachmentDoc>() { IsSuccess = true, Model = model }); } catch (Exception ex) { _log.Error(ex, _user.GetCurrentUser().User_Name); return(new Response <AttachmentDoc>() { IsSuccess = false, Message = ex.Message }); } }
public async Task <ActionResult> FileUploadSave([FromBody] AttachmentDoc model) { if (ModelState.IsValid) { try { await _repository.UploadDoc(model); return(Ok(model)); } catch (Exception ex) { throw new JsonException(ex.Message, ex); } } return(BadRequest()); }