public FilmCrewEntity Edit(FilmCrewEntity entity) { FilmCrewEntity entry = null; using (context = new CinemaStoreContext()) { if (entity.Id > 0) { entry = context.FilmCrew.FirstOrDefault(x => x.Id == entity.Id); } else { entry = new FilmCrewEntity(); context.FilmCrew.Add(entry); } entry.FamilyName = entity.FamilyName; entry.GivenName = entity.GivenName; entry.Patronymic = entity.Patronymic; entry.Group = entity.Group; try { context.SaveChanges(); } catch (Exception ex) { throw ex; } } return(entry); }
private FilmCrewEntity GetBy(int id) { FilmCrewEntity entity = null; using (context = new CinemaStoreContext()) { entity = context.FilmCrew.FirstOrDefault(x => x.Id == id); } return(entity); }
public ActionResult Delete(int id = 0) { FilmCrewEntity model = new FilmCrewEntity { Id = id }; if (id > 0) { filmcrewSrv.Delete(model); } return(RedirectToAction("Index")); }
public void Delete(FilmCrewEntity entity) { using (context = new CinemaStoreContext()) { var entry = context.FilmCrew.FirstOrDefault(x => x.Id == entity.Id); context.FilmCrew.Remove(entry); try { context.SaveChanges(); } catch (Exception ex) { throw ex; } } }