public IHttpActionResult Put([FromBody] VMCheckList value) { if (value != null) { CheckList c = VMCheckList.GetCheckList(value, new Guid(UserId)); var g = c.Id; try { using (UnitOfWork m = new UnitOfWork(new MMAContext(), new Guid(UserId), UserEmail)) { //CheckList savedCheckList = m.CheckLists.Get(g); m.CheckLists.Update(g, c); CheckList cc = m.CheckLists.Get(g); VMCheckList v = VMCheckList.GetVmCheckList(cc); return(Ok(v)); } } catch (Exception e) { return(BadRequest(e.GetAllMessages())); } } else { return(BadRequest()); } }
public IHttpActionResult Post([FromBody] VMCheckList value) { //UserId = "2303eff9-b95e-4d3c-8397-bf4eaae25c4f"; bool icheck; try { CheckList c = VMCheckList.GetCheckList(value, new Guid(UserId)); using (UnitOfWork m = new UnitOfWork(new MMAContext(), new Guid(UserId), UserEmail)) { icheck = m.CheckLists.Insert(c); } if (icheck) { return(Created($"/api/CheckList/{c.Id}", VMCheckList.GetVmCheckList(c))); } else { return(BadRequest()); } } catch (Exception e) { return(BadRequest(e.GetAllMessages())); //throw; } }