public void DeleteCharacter(int id) { GotCharacter deletedCharacter = GotCharacterContext.GotCharacters.FirstOrDefault(x => x.Id == id); GotCharacterContext.GotCharacters.Remove(deletedCharacter); GotCharacterContext.SaveChanges(); }
public void AddCharacter(string name, bool isAlive, bool isFavourite) { var character = new GotCharacter() { Name = name, IsAlive = isAlive, IsFavourite = isFavourite }; GotCharacterContext.GotCharacters.Add(character); GotCharacterContext.SaveChanges(); }
public void UpdateCharacter(GotCharacter character) { GotCharacterContext.GotCharacters.Update(character); GotCharacterContext.SaveChanges(); }
public IActionResult Edit(GotCharacter character) { GotCharacterRepository.UpdateCharacter(character); return(RedirectToAction("List")); }