// GET: Day/Edit/5 public ActionResult Edit(int id) { var service = CreateDayService(); var detail = service.GetDayById(id); var model = new DayEdit { DayId = detail.DayId, WeekDay = detail.WeekDay, Sales = detail.Sales }; return(View(model)); }
public bool UpdateDay(DayEdit model) { using (var ctx = new ApplicationDbContext()) { var entity = ctx .Days .Single(e => e.DayID == model.DayID && e.OwnerID == _userId); entity.DayName = model.DayName; entity.Date = model.Date; return(ctx.SaveChanges() == 1); } }
public IHttpActionResult Put(DayEdit day) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var service = CreateDayService(); if (!service.UpdateDay(day)) { return(InternalServerError()); } return(Ok()); }
public bool UpdateDay(DayEdit model) { using (var ctx = new ApplicationDbContext()) { var entity = ctx .Days .Single(e => e.DayId == model.DayId && e.ManagerId == _userId); entity.DayId = model.DayId; entity.DayOfWeek = model.WeekDay; entity.Sales = model.Sales; return(ctx.SaveChanges() == 1); } }
public ActionResult Edit(int id, DayEdit model) { if (!ModelState.IsValid) { return(View(model)); } if (model.DayId != id) { ModelState.AddModelError("", "Id Mismatch"); return(View(model)); } var service = CreateDayService(); if (service.UpdateDay(model)) { TempData["SaveResult"] = "Your data was updated!"; return(RedirectToAction("Index")); } ModelState.AddModelError("", "Your not could not be updated."); return(View()); }