public IActionResult Post([FromBody] DocumentLinkModel model)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }
            var response = service.Add(model);

            if (!response.Success)
            {
                return(BadRequest(response.Message));
            }
            return(Ok(response.ReturnedId));
        }
Ejemplo n.º 2
0
 public ActionResponse Add(DocumentLinkModel model)
 {
     using (var unitWork = new UnitOfWork(context))
     {
         ActionResponse response = new ActionResponse();
         try
         {
             var newLink = unitWork.DocumentLinksRepository.Insert(new EFDocumentLinks()
             {
                 Title      = model.Title,
                 URL        = model.URL,
                 DatePosted = DateTime.Now
             });
             unitWork.Save();
             response.ReturnedId = newLink.Id;
         }
         catch (Exception ex)
         {
             response.Success = false;
             response.Message = ex.Message;
         }
         return(response);
     }
 }