public ActionResult Edit(int id) { // var service = new DeveloperService(); var detail = _developerService.GetDeveloperById(id); var model = new DeveloperEdit() { DeveloperId = detail.DeveloperId, Name = detail.Name, CompanySize = detail.CompanySize, Country = detail.Country, Rating = detail.Rating }; return(View(model)); }
// GET: Edit public ActionResult Edit(int id) { var svc = CreateDeveloperService(); var details = svc.GetDeveloperByID(id); var model = new DeveloperEdit { DeveloperID = details.DeveloperID, DeveloperName = details.DeveloperName, Region = details.Region, IsMajor = details.IsMajor, IsActive = details.IsActive }; return(View(model)); }
public bool UpdateDeveloper(DeveloperEdit model) { using (var ctx = new ApplicationDbContext()) { var entity = ctx.Developers .Find(model.DeveloperID); entity.DeveloperName = model.DeveloperName; entity.Region = model.Region; entity.IsActive = model.IsActive; entity.IsMajor = model.IsMajor; return(ctx.SaveChanges() == 1); } }
public bool UpdateDeveloper(DeveloperEdit model) { using (var ctx = new ApplicationDbContext()) { var entity = ctx .Developers .Single(e => e.DevelopersID == model.DeveloperID && e.OwnerID == _userId); entity.DevelopersID = model.DeveloperID; entity.DevelopersName = model.Name; entity.DevelopersHiredDate = model.DateHired; return(ctx.SaveChanges() == 1); } }
public IHttpActionResult Put(DeveloperEdit developer) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var service = CreateDeveloperService(); if (!service.UpdateDeveloper(developer)) { return(InternalServerError()); } return(Ok()); }
public ActionResult Edit(int id, DeveloperEdit model) { if (!ModelState.IsValid) { return(View(model)); } if (model.DeveloperId != id) { ModelState.AddModelError("", "Id Mismatch"); return(View(model)); } // var service = new DeveloperService(); if (_developerService.UpdateDeveloper(model)) { TempData["SaveResult"] = "The developer was updated."; return(RedirectToAction("Index")); } ModelState.AddModelError("", "Developer could not be updated."); return(View(model)); }
public bool UpdateDeveloper(DeveloperEdit model) { using (var ctx = new ApplicationDbContext()) { var entity = ctx .Developers .Single(e => e.DeveloperId == model.DeveloperId); { entity.FirstName = model.FirstName; entity.MI = model.MI; entity.LastName = model.LastName; entity.Address = model.Address; entity.City = model.City; entity.State = model.State; entity.Zip = model.Zip; entity.Cell = model.Cell; entity.SocialMedia = model.SocialMedia; }; return(ctx.SaveChanges() == 1); } }
public bool UpdateDeveloper(DeveloperEdit model) { using (var ctx = new ApplicationDbContext()) { try { var entity = ctx.Developers.Single(e => e.Id == model.DeveloperId); entity.Name = model.Name; entity.CompanySize = model.CompanySize; entity.Country = model.Country; entity.Rating = model.Rating; entity.ModifiedUtc = DateTimeOffset.Now; return(ctx.SaveChanges() >= 1); } catch (Exception e) { Debug.Print("Exception thrown while looking for developer"); Debug.Print(e.Message); return(false); } } }
public ActionResult Edit(int id, DeveloperEdit model) { if (!ModelState.IsValid) { return(View(model)); } if (model.DeveloperID != id) { ModelState.AddModelError("", "ID mismatch"); return(View(model)); } var svc = CreateDeveloperService(); if (svc.UpdateDeveloper(model)) { TempData["SaveResult"] = "Developer info successfully updated!"; return(RedirectToAction("Index")); } ModelState.AddModelError("", "An error occurred while attempting to edit the developer info - changes not saved."); return(View(model)); }