コード例 #1
0
 public dynamic Put(int id, MvFieldInput input)
 {
     if (ModelState.IsValid && input != null)
     {
         using (var cnt = new MvContext())
         {
             var item = cnt.Fields.Where(t => t.Id == id).SingleOrDefault();
             if (item != null)
             {
                 item.IsRequired = input.IsRequired;
                 item.Title      = input.Title;
                 item.Order      = input.Order;
                 item.Modified   = DateTime.Now;
                 cnt.SaveChanges();
                 return(new { Id = item.Id });
             }
         }
     }
     return(new { });
 }
コード例 #2
0
 // POST api/values
 public dynamic Post(int listId, MvFieldInput input)
 {
     if (ModelState.IsValid && input != null)
     {
         using (var cnt = new MvContext())
         {
             if (cnt.Lists.Any(t => t.Id == listId))
             {
                 var field = new MvField()
                 {
                     ListId = listId, Format = (int)input.Format, IsRequired = input.IsRequired, Title = input.Title, Order = input.Order, Modified = DateTime.Now
                 };
                 cnt.Fields.Add(field);
                 cnt.SaveChanges();
                 return(new { Id = field.Id });
             }
         }
     }
     return(new { });
 }