// GET api/CheckListItem/5
 public IHttpActionResult Get(string id)
 {
     try
     {
         Guid g = new Guid(id);
         //UserId = "2303eff9-b95e-4d3c-8397-bf4eaae25c4f";
         using (UnitOfWork m = new UnitOfWork(new MMAContext(), new Guid(UserId), UserEmail))
         {
             VMCheckListItem vm = VMCheckListItem.GetVmCheckListItem(m.CheckListItems.Get(g));
             if (vm == null)
             {
                 return(NotFound());
             }
             else
             {
                 return(Ok(vm));
             }
         }
     }
     catch (Exception ex)
     {
         //todo Log Exception
         return(BadRequest(ex.GetAllMessages()));
     }
 }
 public IHttpActionResult GetByList([FromUri] string strCheckListId)
 {
     try
     {
         Guid g = new Guid(strCheckListId);
         using (ApplicationDbContext db = new ApplicationDbContext())
         {
             using (UnitOfWork m = new UnitOfWork(new MMAContext(), new Guid(UserId), UserEmail))
             {
                 var l = m.CheckListItems.GetByList(g);
                 List <VMCheckListItem> al = new List <VMCheckListItem>(l.Count());
                 foreach (var r in l)
                 {
                     al.Add(VMCheckListItem.GetVmCheckListItem(r));
                 }
                 return(Ok(al));
             }
         }
     }
     catch (Exception e)
     {
         //ToDo Log exception
         return(BadRequest(e.GetAllMessages()));
     }
 }
 // POST api/CheckListItem
 public IHttpActionResult Post([FromBody] VMCheckListItem value)
 {
     //UserId = "2303eff9-b95e-4d3c-8397-bf4eaae25c4f";
     try
     {
         CheckListItem c = VMCheckListItem.GetCheckListItem(value);
         using (UnitOfWork m = new UnitOfWork(new MMAContext(), new Guid(UserId), UserEmail))
         {
             //m.CheckListItems.Add(c);
             //m.Complete();
             m.CheckListItems.Insert(c);
         }
         return(Created($"/api/CheckListItem/{c.Id}", VMCheckListItem.GetVmCheckListItem(c)));
     }
     catch (Exception e)
     {
         return(BadRequest(e.GetAllMessages()));
         //throw;
     }
 }
        // PUT api/CheckListItem/5
        public IHttpActionResult Put(string id, [FromBody] VMCheckListItem value)
        {
            var g = new Guid(id);

            try
            {
                using (UnitOfWork m = new UnitOfWork(new MMAContext(), new Guid(UserId), UserEmail))
                {
                    //VMCheckListItem.UpdateCheckListItem(value, c);
                    //m.Complete();
                    m.CheckListItems.Update(g, VMCheckListItem.GetCheckListItem(value));
                    CheckListItem   c = m.CheckListItems.Get(g);
                    VMCheckListItem v = VMCheckListItem.GetVmCheckListItem(c);
                    return(Ok(v));
                }
            }
            catch (Exception e)
            {
                return(BadRequest(e.GetAllMessages()));
            }
        }