/// <summary> /// This allow a drivers information to be changed /// </summary> /// <param name="driver"></param> /// <returns>"The driver was successfully updated."</returns> public IHttpActionResult Put(DriverEdit driver) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var service = CreateDriverService(); if (!service.UpdateDriver(driver)) { return(InternalServerError()); } return(Ok("The driver was successfully updated.")); }
public ActionResult Edit(int id) { var service = CreateDriverService(); var detail = service.GetDriverById(id); var model = new DriverEdit { DriverId = detail.DriverId, FirstName = detail.FirstName, LastName = detail.LastName, Age = detail.Age, LicenseNumber = detail.LicenseNumber, SpaceshipMake = detail.SpaceshipMake }; return(View(model)); }
public bool UpdateDriver(DriverEdit model) { using (var ctx = new ApplicationDbContext()) { var entity = ctx .Drivers .Single(e => e.DriverId == model.DriverId && e.OwnerId == _userId); entity.FirstName = model.FirstName; entity.LastName = model.LastName; entity.Age = model.Age; entity.LicenseNumber = model.LicenseNumber; entity.SpaceshipMake = model.SpaceshipMake; return(ctx.SaveChanges() == 1); } }
/// <summary> /// This allows you to update the drivers information. /// </summary> /// <param name="model">This is the model of the drivers updated information</param> /// <returns></returns> public bool UpdateDriver(DriverEdit model) { using (var ctx = new ApplicationDbContext()) { var entity = ctx .Drivers .Single(e => e.DriverId == model.DriverId && e.ApplicationUser == _userId); entity.DriverFirstName = model.DriverFirstName; entity.DriverLastName = model.DriverLastName; entity.HourlyRate = model.HourlyRate; entity.Location = model.Location; entity.TypeOfBoat = model.TypeOfBoat; entity.DaysAvailable = model.DaysAvailable; entity.MaximumOccupants = model.MaximumOccupants; return(ctx.SaveChanges() == 1); } }
public ActionResult Edit(int id, DriverEdit model) { if (!ModelState.IsValid) { return(View(model)); } if (model.DriverId != id) { ModelState.AddModelError("", "Id Mismatch"); return(View(model)); } var service = CreateDriverService(); if (service.UpdateDriver(model)) { TempData["SaveResult"] = "Your info has been updated!"; return(RedirectToAction("Index")); } ModelState.AddModelError("", "Your info could not be changed."); return(View(model)); }
virtual public void SelectAll() { DriverEdit.SelectAll(); }
virtual public void Clear() { DriverEdit.Clear(); }
virtual public void Append(string txt) { DriverEdit.Append(txt); }
virtual public int RemoveIndex(int index) { return(DriverEdit.RemoveIndex(index)); }
virtual public void Append(object obj) { DriverEdit.Append(obj); }