public bool UpdateAchievement(AchievementEdit model) { using (var ctx = new ApplicationDbContext()) { var entity = ctx.Achievements.Single(e => e.AchievementID == model.AchievementID && e.VideoGameID == model.VideoGameID); entity.AchievementName = model.AchievementName; entity.AchievementNotes = model.AchievementNotes; entity.AchievementCompleted = model.AchievementCompleted; return(ctx.SaveChanges() == 1); } }
public ActionResult AchievementEdit(int id) { var service = CreateAchievementService(); var detail = service.AchievementDetails(id); var model = new AchievementEdit { AchievementID = detail.AchievementID, AchievementName = detail.AchievementName, AchievementNotes = detail.AchievementNotes, AchievementCompleted = detail.AchievementCompleted, VideoGameID = detail.VideoGameID }; return(View(model)); }
public ActionResult Edit(int id) { Create(); var service = CreateAchieveService(); var detail = service.GetAchieveById(id); var model = new AchievementEdit { AchievementID = detail.AchievementID, GameID = detail.GameID, Char_Name = detail.Char_Name, Achievement = detail.Achievement }; return(View(model)); }
public bool UpdateAchieve(AchievementEdit model) { using (var ctx = new ApplicationDbContext()) { var entity = ctx .Achievements .Single(e => e.AchievementID == model.AchievementID && e.OwnerID == _userId); entity.Char_Name = model.Char_Name; //entity.GameTitle = (Data.Game?)model.GameTitle; entity.Achievement = model.Achievement; entity.ModifiedUtc = DateTimeOffset.UtcNow; return(ctx.SaveChanges() == 1); } }
public ActionResult Edit(int id, AchievementEdit model) { if (!ModelState.IsValid) { return(View(model)); } if (model.AchievementID != id) { ModelState.AddModelError("", "Id Mismatch"); return(View(model)); } var service = CreateAchieveService(); if (service.UpdateAchieve(model)) { TempData["SaveResult"] = "Your Achievement was updated."; return(RedirectToAction("Index")); } ModelState.AddModelError("", "Your Achievement could not be updated."); return(View()); }