public async Task <IActionResult> Post([FromForm] AddEmailViewModel request) { try { //create email entity EmailModel email = _manager.CreateEmail(request); //create email attachments & binary objects entities; upload binary object files to server var attachments = new List <EmailAttachment>(); if (request.Files != null) { attachments = _manager.AddAttachments(request.Files, email.Id.Value, request.DriveName); } EmailViewModel emailViewModel = _manager.GetEmailViewModel(email, attachments); await base.PostEntity(email); return(Ok(emailViewModel)); } catch (Exception ex) { return(ex.GetActionResult()); } }
public async Task <IActionResult> Post([FromForm] AddEmailViewModel request) { try { //create email entity EmailModel email = manager.CreateEmail(request); await base.PostEntity(email); //create email attachments & binary objects entities; upload binary object files to server var attachments = manager.AddAttachments(request.Files, (Guid)email.Id); EmailViewModel emailViewModel = manager.GetEmailViewModel(email, attachments); return(Ok(emailViewModel)); } catch (Exception ex) { ModelState.AddModelError("Email", ex.Message); return(BadRequest(ModelState)); } }