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));
 }
Ejemplo n.º 2
0
 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));
 }
Ejemplo n.º 3
0
 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 }));
     }
 }
Ejemplo n.º 4
0
 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));
 }
Ejemplo n.º 5
0
 public void Save()
 {
     _context.SaveChanges();
 }
Ejemplo n.º 6
0
 public void Commit()
 {
     _context.SaveChanges();
 }