示例#1
0
 private ActionResult Update <T>(CollectionViewEditRequest <T> requestData, DbSet <T> data) where T : class
 {
     return(this.C1Json(CollectionViewHelper.Edit <T>(requestData, item =>
     {
         string error = string.Empty;
         bool success = true;
         try
         {
             _db.Entry(item as object).State = EntityState.Modified;
             _db.SaveChanges();
         }
         catch (Exception e)
         {
             error = GetExceptionMessage(e);
             success = false;
         }
         return new CollectionViewItemResult <T>
         {
             Error = error,
             Success = success,
             Data = item
         };
     }, () => data.ToList <T>())));
 }
示例#2
0
 public ActionResult ListUpdateProducts([C1JsonRequest] CollectionViewEditRequest <Product> requestData)
 {
     return(this.C1Json(CollectionViewHelper.Edit <Product>(requestData, item =>
     {
         string error = string.Empty;
         bool success = true;
         try
         {
             _db.Entry(item as object).State = EntityState.Modified;
             _db.SaveChanges();
         }
         catch (Exception e)
         {
             error = GetExceptionMessage(e);
             success = false;
         }
         return new CollectionViewItemResult <Product>
         {
             Error = error,
             Success = success,
             Data = item
         };
     }, () => _db.Products.ToList <Product>())));
 }