Beispiel #1
0
        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);
        }
Beispiel #2
0
        private FilmCrewEntity GetBy(int id)
        {
            FilmCrewEntity entity = null;

            using (context = new CinemaStoreContext())
            {
                entity = context.FilmCrew.FirstOrDefault(x => x.Id == id);
            }
            return(entity);
        }
Beispiel #3
0
        public ActionResult Delete(int id = 0)
        {
            FilmCrewEntity model = new FilmCrewEntity {
                Id = id
            };

            if (id > 0)
            {
                filmcrewSrv.Delete(model);
            }

            return(RedirectToAction("Index"));
        }
Beispiel #4
0
 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;
         }
     }
 }