public ActionResult Edit(Film film, int[] Countries, int[] Janrs)
      {
          var entity = context.Entry(film);

          entity.State = System.Data.Entity.EntityState.Modified;

          context.SaveChanges();
          DeleteRelationShip(film);

          foreach (var i in Countries)
          {
              FilmCountry filmCountry = new FilmCountry();
              filmCountry.FilmId    = film.Id;
              filmCountry.CountryId = i;
              context.FilmCountry.Add(filmCountry);

              context.SaveChanges();
          }
          foreach (var i in Janrs)
          {
              FilmJanr janr = new FilmJanr();

              janr.FilmId = film.Id;
              janr.JanrId = i;
              context.FilmJanr.Add(janr);
              context.SaveChanges();
          }
          return(RedirectToAction("Index"));
      }
예제 #2
0
        public ActionResult Form(Film film, int [] Contr, int[] Gen)
        {
            if (film.Name == null || film.YayimTarixi == null || film.Duration == null)
            {
                return(RedirectToAction("index", "home"));
            }
            db.Films.Add(film);
            db.SaveChanges();
            foreach (int item in Contr)
            {
                FilmCountry filmCon = new FilmCountry()
                {
                    FilmId    = film.Id,
                    CountryId = item
                };
                db.FilmCountries.Add(filmCon);
                db.SaveChanges();
            }
            foreach (int item in Gen)
            {
                FillmGenre filmGenre = new FillmGenre()
                {
                    FilmId  = film.Id,
                    GenreId = item
                };
                db.FillmGenres.Add(filmGenre);
                db.SaveChanges();
            }

            return(RedirectToAction("index", "home"));
        }
      public ActionResult Create(FilmList model, CountryJanrListModel listModel)
      {
          context.Film.Add(model.Film);
          context.SaveChanges();

          var filmCountries = new FilmCountry();

          if (listModel.Countries == null || listModel.Janrs == null)
          {
              ViewBag.ErrorMessage = "Daxil edin";
          }
          else
          {
              foreach (var item in listModel.Countries)
              {
                  filmCountries.CountryId = item;
                  filmCountries.FilmId    = model.Film.Id;
                  context.FilmCountry.Add(filmCountries);
                  context.SaveChanges();
              }


              var filmJanr = new FilmJanr();
              foreach (var item in listModel.Janrs)
              {
                  filmJanr.JanrId = item;
                  filmJanr.FilmId = model.Film.Id;
                  context.FilmJanr.Add(filmJanr);
                  context.SaveChanges();
              }
          }
          return(Redirect("Create"));
      }
예제 #4
0
 public override FilmCountry Add(FilmCountry entity)
 {
     if (entity.Id.Equals(Guid.Empty))
     {
         _context.FilmCountries().Add(entity);
     }
     return((entity == null) ? null : (FilmCountry)entity.Clone());
 }
예제 #5
0
        public void AddCountry()
        {
            string            abbrev      = GetAString("A country abbreviation");
            CountryRepository countryRepo = _factory.CreateCountryRepository();
            Country           c           = countryRepo.GetByAbreviation(abbrev);
            FilmCountry       fc          = new FilmCountry();

            fc.FilmId    = CurrentFilm.Id;
            fc.CountryId = c.Id;
            FilmCountryRepository filmCountryRepo = _factory.CreateFilmCountryRepository();

            filmCountryRepo.Add(fc);
        }
예제 #6
0
 public override FilmCountry Add(FilmCountry entity)
 {
     if (entity == null)
     {
         throw new Exception("Null argument");
     }
     if (entity.Id.Equals(Guid.Empty))
     {
         entity.Id = Guid.NewGuid();
         _entities.Add(entity);
     }
     return((FilmCountry)entity.Clone());
 }
예제 #7
0
        private void bntAdd_Click(object sender, EventArgs e)
        {
            FilmCountry filmCon = new FilmCountry();
            FilmGenre   filmGen = new FilmGenre();

            filmCon.FilmID    = FindFilmIdByName();
            filmCon.CountryID = FindCountryIdByName();
            filmGen.FilmID    = FindFilmIdByName();
            filmGen.GenreID   = FindGenreIdByName();
            db.FilmCountries.Add(filmCon);
            db.FilmGenres.Add(filmGen);
            db.SaveChanges();
            MessageBox.Show("successfully sent");
        }
예제 #8
0
        internal void Addountry()
        {
            StringDialog dialog = new StringDialog("A country abbreviation");

            dialog.ShowDialog();
            if (dialog.Accept)
            {
                string abbreviation             = dialog.YourString;
                AbstractCountryRepository cRepo = _countryRepository;
                Country     c  = cRepo.GetByAbbreviation(abbreviation);
                FilmCountry fc = new FilmCountry();
                fc.FilmId    = CurrentFilm.Id;
                fc.CountryId = c.Id;
                AbstractFilmCountryRepository fcRepo = _filmCountryRepository;
                fcRepo.Add(fc);
            }
        }
예제 #9
0
        public ActionResult Update(Film films, int[] countryIds, int[] janreIds)
        {
            if (films.Name != null &&
                films.PublicationDate != null &&
                films.Link != null &&
                janreIds != null &&
                countryIds != null &&
                films.Duration != 0)
            {
                User user = Session["User"] as User;
                films.UserId          = user.Id;
                db.Entry(films).State = System.Data.Entity.EntityState.Modified;
                db.SaveChanges();
                DeleteRelations(films.Id);
                foreach (int item in countryIds)
                {
                    FilmCountry filmCountry = new FilmCountry()
                    {
                        FilmId    = films.Id,
                        CountryId = item
                    };
                    db.FilmCountries.Add(filmCountry);
                    db.SaveChanges();
                }

                foreach (int item in janreIds)
                {
                    FilmJanre filmGenre = new FilmJanre()
                    {
                        FilmId  = films.Id,
                        JanreId = item
                    };
                    db.FilmJanres.Add(filmGenre);
                    db.SaveChanges();
                }

                return(RedirectToAction("Index", "Home"));
            }
            return(Content("Xanalai doldurun"));
        }
예제 #10
0
 public override void Update(FilmCountry entity)
 {
     _context.StateChanged(entity);
     _context.Save();
 }
예제 #11
0
        public override FilmCountry GetById(Guid id)
        {
            FilmCountry entity = _context.FilmCountries().Single(fc => fc.Id.Equals(id));

            return((entity == null) ? null : (FilmCountry)entity.Clone());
        }
예제 #12
0
 public override void Delete(FilmCountry entity)
 {
     _context.FilmCountries().Remove(entity);
 }
예제 #13
0
        public override void Update(FilmCountry entity)
        {
            FilmCountry storedEntity = _entities.Single(fc => fc.Id.Equals(entity.Id));

            storedEntity.Copy(entity);
        }
예제 #14
0
 public override void Delete(FilmCountry entity)
 {
     _entities.Remove(entity);
 }