public virtual void Delete(AttendeeViewModel model, ModelStateDictionary modelState) { var entity = model.ToEntity(); db.Attendees.Attach(entity); // TODO: here should verify the room id is not in the meeting tables db.Attendees.Remove(entity); db.SaveChanges(); }
public JsonResult EditingPopup_Create([DataSourceRequest] DataSourceRequest request, AttendeeViewModel rvm) { if (rvm != null && ModelState.IsValid) { service.Insert(rvm, ModelState); } return Json(new[] { rvm }.ToDataSourceResult(request, ModelState)); }
private bool ValidateModel(AttendeeViewModel room, ModelStateDictionary modelState) { //if (appointment.Start > appointment.End) //{ // modelState.AddModelError("errors", "End date must be greater or equal to Start date."); // return false; //} return true; }
public virtual void Update(AttendeeViewModel model, ModelStateDictionary modelState) { if (ValidateModel(model, modelState)) { if (string.IsNullOrEmpty(model.Text)) { model.Text = ""; } if (model.Value < 0) { model.Value = 100; } var entity = model.ToEntity(); db.Attendees.Attach(entity); db.Entry(entity).State = System.Data.Entity.EntityState.Modified; db.SaveChanges(); } }
public virtual void Insert(AttendeeViewModel model, ModelStateDictionary modelState) { if (ValidateModel(model, modelState)) { if (string.IsNullOrEmpty(model.Text)) { model.Text = ""; } if (model.Value < 0) { model.Value = 100; } var entity = model.ToEntity(); db.Attendees.Add(entity); db.SaveChanges(); model.ID = entity.ID; } }
public JsonResult EditingPopup_Destroy([DataSourceRequest] DataSourceRequest request, AttendeeViewModel rvm) { if (rvm != null) { service.Delete(rvm, ModelState); } return Json(new[] { rvm }.ToDataSourceResult(request, ModelState)); }