示例#1
0
 public ActionResult VisitTypeDestroy([DataSourceRequest] DataSourceRequest request, VisitTypeModel dictionary)
 {
     if (dictionary != null)
     {
         var dbVisitType = db.VisitTypes.Single(x => x.Id == dictionary.Id);
         db.VisitTypes.Remove(dbVisitType);
         db.SaveChanges();
     }
     return(Json(new[] { dictionary }.ToDataSourceResult(request, ModelState)));
 }
示例#2
0
 public ActionResult VisitTypeUpdate([DataSourceRequest] DataSourceRequest request, VisitTypeModel dictionary)
 {
     if (dictionary != null && ModelState.IsValid)
     {
         if (dictionary.Time <= 0 || dictionary.Time > 1440)
         {
             ModelState.AddModelError("Message", Convert.ToString("Время должно быть не более 1440 минут и больше 0 минут"));
             return(Json(new[] { dictionary }.ToDataSourceResult(request, ModelState)));
         }
         var dbVisitType = db.VisitTypes.Single(x => x.Id == dictionary.Id);
         dbVisitType.Group = dictionary.CategoryName;
         dbVisitType.Name  = dictionary.Name;
         dbVisitType.Time  = dictionary.Time;
         db.SaveChanges();
     }
     return(Json(new[] { dictionary }.ToDataSourceResult(request, ModelState)));
 }