private String AddCinemaGroup(CinemaGroup cinemaGroup) { RepoCinmaGroup = new CinemaGroupRepository(); RepoCinmaGroup.AddNew(cinemaGroup); RepoCinmaGroup.DBSave(); return(cinemaGroup.Name + " , - id : " + cinemaGroup.Id); }
public int AddNew(CinemaGroup obj) { _Db = new EGMoviesWorkshopDB(); _Db.CinemaGroups.Add(obj); _Db.Entry(obj).State = System.Data.Entity.EntityState.Added; _Db.SaveChanges(); return(obj.Id); }
public ActionResult Details(int id) { CinemaRepository repoCinema = new CinemaRepository(); Cinema cinema = repoCinema.GitCinemaByCinemaId(id); CinemaGroup cinemaGroup = repoCinema.GitCinemaGroupByCinemaId(id); List <Show> shows = repoCinema.GitShowsByCinemaId(id); CinemaDetailsViewModel cinemaDetailsViewModel = new CinemaDetailsViewModel { Cinema = cinema, CinemaGroup = cinemaGroup, Shows = shows }; return(View(cinemaDetailsViewModel)); }
private void btnGenerateData_Click(object sender, EventArgs e) { XmlDocument xmlDoc = new XmlDocument(); var rootxDoc = XDocument.Load(FilePath); int cinmagroupIndex = 0; int cinmaIndex = 0; int showIndex = 0; int movieIndex = 0; int movieIndexFounded = 0; int actorIndex = 0; #region rgnCinemaGroup //add CinemaGroups foreach (var cinmagroup in rootxDoc.Descendants().Where(cg => cg.Name.LocalName.Equals("CinemaGroup"))) { cinmagroupIndex++; ObjCinemaGroup = new CinemaGroup(); ObjCinemaGroup.Id = cinmagroupIndex; ObjCinemaGroup.Name = cinmagroup.Attribute("Name").Value; ObjCinemaGroup.City = cinmagroup.Element("City")?.Value; ObjCinemaGroup.Area = cinmagroup.Element("Area")?.Value; ObjCinemaGroup.Address = cinmagroup.Element("Address")?.Value; ObjCinemaGroup.Telephone = cinmagroup.Element("Telephone")?.Value; ObjCinemaGroup.Description = cinmagroup.Element("Description")?.Value; //RepoCinmaGroup.AddNew(); //MessageBox.Show(AddCinemaGroup(ObjCinemaGroup)); AddCinemaGroup(ObjCinemaGroup); #region rgnCinema //add Cinemas foreach (var cinma in cinmagroup.Descendants().Where(cg => cg.Name.LocalName.Equals("Cinema"))) { cinmaIndex++; ObjCinema = new Cinema(); ObjCinema.Id = cinmaIndex; ObjCinema.Name = cinma.Attribute("Name").Value; ObjCinema.CinemaGroupId = cinmagroupIndex; // ObjCinema.CinemaGroup = ObjCinemaGroup; //RepoCinema.AddNew(); //MessageBox.Show(AddCinema(ObjCinema)); AddCinema(ObjCinema); #region rgnMovie // add Shows foreach (var shw in cinma.Descendants().Where(cg => cg.Name.LocalName.Equals("Show"))) { showIndex++; ObjShow = new Show(); // add movies foreach (var mov in shw.Descendants().Where(cg => cg.Name.LocalName.Equals("Movie"))) { movieIndex++; ObjMovie = new Movie(); RepoMovie = new MovieRepository(); if (!RepoMovie.GitIDByName(mov.Attribute("Name").Value.ToString(), out movieIndexFounded)) { //add new movie ObjMovie.Id = movieIndex; ObjMovie.Name = mov.Attribute("Name").Value.Trim(); ObjMovie.Genre = mov.Element("Genre")?.Value; ObjMovie.ShowingDate = DateTime.ParseExact(mov.Element("ShowingDate")?.Value.ToString(), "dd/MM/yyyy", null); ObjMovie.Description = mov.Element("Description")?.Value; // MessageBox.Show(AddMovie(ObjMovie)); //AddMovie(ObjMovie); List <Actor> listActors = new List <Actor>(); foreach (var actor in mov.Descendants().Where(cg => cg.Name.LocalName.Equals("Actor"))) { actorIndex++; ObjActor = new Actor(); ObjActor.Id = actorIndex; ObjActor.Name = actor.Attribute("Name").Value.Trim(); ObjActor.Role = actor.Attribute("Role").Value.Trim(); listActors.Add(ObjActor); } ObjMovie.Actors = listActors; AddMovie(ObjMovie); listActors = null; } } #region rgnShow ObjShow.Id = showIndex; ObjShow.ShowFrom = shw.Attribute("From").Value; ObjShow.ShowTo = shw.Attribute("To").Value; ObjShow.CinemaId = cinmaIndex; if (movieIndexFounded == 0) { ObjShow.MovieId = movieIndex; } else { ObjShow.MovieId = movieIndexFounded; movieIndexFounded = 0; movieIndex--; } //MessageBox.Show(AddShow(ObjShow)); AddShow(ObjShow); #endregion #endregion } #endregion } } #endregion MessageBox.Show("All Data Saved Succefully"); }
public CinemaGroupRepository() { _Db = new EGMoviesWorkshopDB(); _obj = new CinemaGroup(); }