public async Task <IHttpActionResult> PutSchedule(int id, Schedule schedule) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != schedule.ID) { return(BadRequest()); } db.Entry(schedule).State = EntityState.Modified; try { await db.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!ScheduleExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public async Task <IHttpActionResult> PutCustomer(string id, Customer customer) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != customer.ID) { return(BadRequest()); } db.Entry(customer).State = EntityState.Modified; try { await db.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!CustomerExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public async Task <ActionResult> Edit([Bind(Include = "Id,TrainingTimeStart")] TrainingSession trainingSession) { if (ModelState.IsValid) { db.Entry(trainingSession).State = EntityState.Modified; await db.SaveChangesAsync(); return(RedirectToAction("Index")); } return(View(trainingSession)); }
public async Task <ActionResult> Edit([Bind(Include = "Id,Name,LastName,Price,TrainingLength,Description")] Coach coach) { if (ModelState.IsValid) { db.Entry(coach).State = EntityState.Modified; await db.SaveChangesAsync(); return(RedirectToAction("Index")); } return(View(coach)); }
public async Task <ActionResult> Edit([Bind(Include = "Id,Name,LastName,EMail,PhoneNumber")] Client client) { if (ModelState.IsValid) { db.Entry(client).State = EntityState.Modified; await db.SaveChangesAsync(); return(RedirectToAction("Index")); } return(View(client)); }
public void UpdateClient(Client client) { try { _dbContext.Attach(client); _dbContext.Entry(client).State = EntityState.Modified; _dbContext.SaveChanges(); } catch (Exception ex) { Console.WriteLine(ex); } }