public ActionResult Create([Bind(Include = "Name, Description, PricePerMinute")] Service service) { try { if (ModelState.IsValid) { db.Services.Add(service); db.SaveChanges(); return(RedirectToAction("Index")); } } catch (DataException) { //Log the error ModelState.AddModelError("", PageStrings.CreateErrorMessageText); } return(View(service)); }
public ActionResult Create([Bind(Include = "Person,PhoneNumber")] Client client) { try { if (ModelState.IsValid) { db.Clients.Add(client); db.SaveChanges(); return(RedirectToAction("Index", "ProvidedService", new { clientId = client.Id })); } } catch (DataException) { //Log the error ModelState.AddModelError("", PageStrings.CreateErrorMessageText); } return(View(client)); }
public JsonResult InWait(int id) { try { CarInfo car = db.CarInfos.Find(id); if (car == null) { Response.StatusCode = (int)HttpStatusCode.NotFound; return(Json(new { Result = "Error" })); } car.Status = "W pracy"; db.Entry(car).State = EntityState.Modified; db.SaveChanges(); return(Json(new { Result = "OK" })); } catch (Exception ex) { return(Json(new { Result = "ERROR", Message = ex.Message })); } }
public ActionResult Create([Bind(Include = "ServiceDate,NumberOfMinutes,ClientId,ServiceId")] ProvidedService providedService) { try { if (ModelState.IsValid) { db.ProvidedServices.Add(providedService); db.SaveChanges(); return(RedirectToAction("Index", new { clientId = providedService.ClientId })); } } catch (RetryLimitExceededException) { //Log the error ModelState.AddModelError("", PageStrings.CreateErrorMessageText); } PopulateClientsDropDownList(providedService.ClientId); PopulateServicesDropDownList(providedService.ServiceId); return(View(providedService)); }
public void Save() { _context.SaveChanges(); }
public void Commit() { _context.SaveChanges(); }