private static List <Play> createPlays(Theatre theatre, int num) { var plays = new List <Play>(); int imageSeed = 160; for (int i = 0; i < num; i++) { string id = ((i + 7) ^ 7).ToString(); plays.Add(new Play { Id = id, Name = Lorem.Words(1, 4), Description = Lorem.Paragraph(2, 4), Duration = new Random().Next(1, 3), ImagesUrls = GetImages(imageSeed, 4), TheatreId = theatre.Id, //PlayDateTimes PlayDateTimesIds = new List <string>(), Published = true }); theatre.PlaysIds.Add(id); imageSeed += 20; } return(plays); }
public async Task DeleteTheatreTest() { //Arrange var options = Utilities.GetOptions(nameof(DeleteTheatreTest)); var testTheatre00 = new Theatre() { Id = Guid.NewGuid(), Name = "TestName", AboutInfo = "TestAboutInfo", Location = "TestLocation", Phone = "0896663554", }; using (var assertContext = new TheatreContext(options)) { await assertContext.Theatres.AddAsync(testTheatre00); await assertContext.SaveChangesAsync(); var serviceTest = new TheatreService(assertContext); var result = await serviceTest.DeleteTheatreAsync(testTheatre00.Id); await assertContext.SaveChangesAsync(); } using (var assertContext = new TheatreContext(options)) { var result = await assertContext.Theatres.FirstAsync(); Assert.AreEqual(true, result.IsDeleted); } }
public void VisitTheatre(Theatre theatre) { //string result = $"<html>\n\t<body>\n\t\t<p>{theatre.Title}</p>\n\t\t<p>{theatre.CountOfAttractions}</p>\n\t</body>\n</html>"; string result = $"<html>\n <body>\n <p>{theatre.Title}</p>\n <p>{theatre.CountOfAttractions}</p>\n </body>\n</html>\n"; Console.WriteLine(result); }
private HashSet <Theatre> getTheatersWithMovies(string date, string lat, string lon, string radius, string units) { string requestString = String.Format( "http://data.tmsapi.com/v1.1/movies/showings?" + TMS_API_DATE_PARAM + "{0}" + "&" + TMS_API_RADIUS_PARAM + "{1}" + "&" + TMS_API_UNITS_PARAM + "{2}" + "&" + TMS_API_LATITUDE_PARAM + "{3}" + "&" + TMS_API_LONGITUDE_PARAM + "{4}" + "&" + TMS_API_KEY_SET_PARAM, date, radius, units, lat, lon); string responseString = wc.DownloadString(requestString); //string responseString = System.IO.File.ReadAllText(@"C:\Users\isk\Desktop\minn_response_json.txt"); var gmapsMovies = JsonConvert.DeserializeObject <List <MovieTh> >(responseString); HashSet <Theatre> uniqueTheatersSet = new HashSet <Theatre>(); foreach (MovieTh currentMovie in gmapsMovies) { foreach (Showtime currentShowtime in currentMovie.Showtimes) { uniqueTheatersSet.Add(currentShowtime.Theatre); Theatre myTh = uniqueTheatersSet.First(x => x.Equals(currentShowtime.Theatre)); myTh.Movies.Add(new MovieShort(currentMovie.Title, currentShowtime.DateTime)); //add to the theater current movie from upper loop and current time of the movie from currentshowtime.datetime } } return(uniqueTheatersSet); }
public async Task ValidTheatre() { //Arrange var options = Utilities.GetOptions(nameof(ValidTheatre)); var testTheatre = new Theatre() { Id = Guid.NewGuid(), Name = "TestName", AboutInfo = "TestAboutInfo", Location = "TestLocation", Phone = "0896663554", }; using (var assertContext = new TheatreContext(options)) { var sut = new TheatreService(assertContext); var result = await sut.CreateTheatreAsync(testTheatre); Assert.IsInstanceOfType(result, typeof(Theatre)); Assert.AreEqual(testTheatre.Name, result.Name); Assert.AreEqual(testTheatre.AboutInfo, result.AboutInfo); Assert.AreEqual(testTheatre.Location, result.Location); Assert.AreEqual(testTheatre.Phone, result.Phone); } }
public async Task ReturnCorrectTheatre() { var options = Utilities.GetOptions(nameof(DeleteTheatreTest)); var testTheatre02 = new Theatre() { Id = Guid.NewGuid(), Name = "TestName", AboutInfo = "TestAboutInfo", Location = "TestLocation", Phone = "0896663554", }; using (var assertContext = new TheatreContext(options)) { await assertContext.Theatres.AddAsync(testTheatre02); await assertContext.SaveChangesAsync(); } using (var assertContext = new TheatreContext(options)) { var sut = new TheatreService(assertContext); var result = await sut.DeleteTheatreAsync(testTheatre02.Id); Assert.IsInstanceOfType(result, typeof(Theatre)); Assert.AreEqual(testTheatre02.Id, result.Id); Assert.AreEqual(testTheatre02.Name, result.Name); Assert.AreEqual(testTheatre02.AboutInfo, result.AboutInfo); Assert.AreEqual(testTheatre02.Location, result.Location); Assert.AreEqual(testTheatre02.Phone, result.Phone); } }
protected void updatebtn_Click(object sender, EventArgs e) { MovieSchedule ms = new MovieSchedule(); ms.Id = Convert.ToInt32(iddropdown.SelectedValue); Movie m = new Movie(); m = movieschedule_controller.GetMovieId(Moviedropdown.SelectedValue); ms.MovieId = m.Id; Theatre t = new Theatre(); t = movieschedule_controller.GetTheatreId(theatredropdown.SelectedValue); ms.TheatreId = t.Id; Timing timing = new Timing(); timing = movieschedule_controller.GetTimingId(timingdropdown.SelectedValue); ms.TimingId = timing.Id; ms.ScheduleDate = Convert.ToDateTime(scheddatetxt.Text); movieschedule_controller.UpdateSchedule(ms); status.Text = " Schedule updated successfully"; }
protected override void ExecuteInsertPerformanceCommand(string[] commandWords) { IVenue venue; switch (commandWords[2]) { case "theatre": venue = this.GetVenue(commandWords[5]); var theatre = new Theatre( commandWords[3], decimal.Parse(commandWords[4]), venue, DateTime.Parse(commandWords[6] + " " + commandWords[7])); this.Performances.Add(theatre); break; case "concert": venue = this.GetVenue(commandWords[5]); var consert = new Concert( commandWords[3], decimal.Parse(commandWords[4]), venue, DateTime.Parse(commandWords[6] + " " + commandWords[7])); this.Performances.Add(consert); break; default: base.ExecuteInsertPerformanceCommand(commandWords); break; } }
public async Task ThorwWhenNoTheatreFound() { var options = Utilities.GetOptions(nameof(ReturnCorrectTheatre)); var secondId = Guid.NewGuid(); var testTheatre05 = new Theatre() { Id = Guid.NewGuid(), Name = "TestName", AboutInfo = "TestAboutInfo", Location = "TestLocation", Phone = "0896663554", }; using (var assertContext = new TheatreContext(options)) { await assertContext.Theatres.AddAsync(testTheatre05); await assertContext.SaveChangesAsync(); } using (var assertContext = new TheatreContext(options)) { var sut = new TheatreService(assertContext); await Assert.ThrowsExceptionAsync <Exception>(() => sut.GetTheatreAsync(secondId)); } }
public ActionResult DeleteTheatre(int id) //Action method for reject the theatre request { Theatre theatre = theatreBl.GetTheatreById(id); theatreBl.DeleteTheatre(theatre); return(RedirectToAction("DisplayTheatre")); }
// Add this object to the theatres collections of MovieTicketing class public bool AddTheatre(Theatre obj) { if (obj.TheatreID == null || obj.TheatreName == null || obj.CityName == null || obj.Address == null || obj.NoOfScreens == null || obj.Screens == null) { Console.WriteLine("The theatre details should not be empty"); } else { obj.DisplayTheatreDetails(); } try { if (obj.NoOfScreens <= 0) { Exceptions.InvalidScreenCountExcpetion n1 = new Exceptions.InvalidScreenCountExcpetion(); } } catch (Exception ex) { Console.WriteLine(ex.Message); } Theatre t1 = obj; return(true); }
static void ProcessPerformance(Theatre theatre, Performance performance, Client client) { Console.WriteLine(); Console.WriteLine($"You've chosen {performance.Name}"); int i = 1; foreach (Ticket ticket in performance) { Console.WriteLine($"{i}: {ticket}"); i++; } Console.WriteLine(); Console.WriteLine("Which ticket do you want to choose?"); Console.WriteLine(); int chosen = Convert.ToInt32(Console.ReadLine()); if (chosen < i && chosen >= 1) { ProcessTicket(theatre, performance, performance[chosen - 1], client); } else { Console.WriteLine(Constants.WrongChoice); } }
private static void Main() { try { Client client = new Client(); Theatre theatre = new Theatre( new Performance("Romeo and Juliet", "Shakespeare", "Tragedy", "10/11/2020 14:00:00"), new Performance("Hamlet", "Shakespeare", "Tragedy", "10/12/2020 14:00:00"), new Performance("A Raisin in the Sun", "Lorraine Hansberry", "Domestic tragedy", "10/13/2020 14:00:00"), new Performance("Hamilton", "Lin-Manuel Miranda", "Musical", "10/14/2020 14:00:00"), new Performance("A Doll's House", "Henrik Ibsen", "Modern tragedy", "10/15/2020 14:00:00"), new Performance("Natalka Poltavka", "Mykola Lysenko", "Opera", "10/16/2020 14:00:00") ); theatre.Inform += AfishaMessageHandler; InitApp(theatre, client); } catch (FormatException e) { Console.WriteLine(e.Message); } }
public ActionResult UpdateTheatre(int id) { Theatre theatre = theatreBl.GetTheatreById(id); SignUpNextModel theatreModel = AutoMapper.Mapper.Map <Theatre, SignUpNextModel>(theatre); return(View(theatreModel)); }
protected void createbtn_Click(object sender, EventArgs e) { MovieSchedule addschedule = new MovieSchedule(); Movie m = new Movie(); m = movieschedule_controller.GetMovieId(Moviedropdown.SelectedValue); addschedule.MovieId = m.Id; Theatre t = new Theatre(); t = movieschedule_controller.GetTheatreId(theatredropdown.SelectedValue); addschedule.TheatreId = t.Id; Timing timing = new Timing(); timing = movieschedule_controller.GetTimingId(timingdropdown.SelectedValue); addschedule.TimingId = timing.Id; addschedule.ScheduleDate = Convert.ToDateTime(scheddatetxt.Text); movieschedule_controller.CreateSchedule(addschedule); MovieSchedule scheduleId = movieschedule_controller.RetrieveLastSchedule(); if (scheduleId != null) { bookingController.InseartSeatsForNewSchedule(scheduleId.Id); } status.Text = "New Schedule created successfully"; }
public Show(Theatre theatre) { for (int i = 0; i < theatre.NumberOfSeats; i++) // <---- And here is my problem!! { //Code to add to list } }
public ActionResult AcceptTheatre(int id) //Action method for accept the theatre request { Theatre theatre = theatreBl.GetTheatreById(id); theatreBl.AcceptRequest(theatre); return(RedirectToAction("DisplayTheatre")); }
public static bool IsShowing(RabbitHole venue, float hours24) { Theatre theatre = venue as Theatre; if (theatre == null) { ComboCriminalTheater theatre2 = venue as ComboCriminalTheater; if (theatre2 == null) { ComboStadiumTheatre theatre3 = venue as ComboStadiumTheatre; if (theatre3 == null) { return(false); } theatre = theatre3.GetTheatre(); } theatre = theatre2.GetTheatre(); } if (theatre == null) { return(false); } return(theatre.IsOpenAt(hours24)); }
public static Household ReturnLotOwner(Lot lot) { Household lotOwner = null; if (lot != null) { //Check first is the lot a rabbit hole lot. List <Theatre> rList = new List <Theatre>(Sims3.Gameplay.Queries.GetObjects <Theatre>()); Theatre rhOnThisLot = null; foreach (Theatre r in rList) { if (r.LotCurrent == lot) { rhOnThisLot = r; break; } } //Is there a rabbit hole on this lot if (rhOnThisLot != null) { List <Household> hList = new List <Household>(Sims3.Gameplay.Queries.GetObjects <Household>()); Sims3.Gameplay.RealEstate.PropertyData pd = null; if (hList != null && hList.Count > 0) { foreach (Household h in hList) { pd = h.RealEstateManager.FindProperty(rhOnThisLot); if (pd != null && pd.Owner != null) { lotOwner = pd.Owner.OwningHousehold; break; } } } } //If the lot is not a RH lot, check for venues if (lotOwner == null) { List <Household> hList = new List <Household>(Sims3.Gameplay.Queries.GetObjects <Household>()); Sims3.Gameplay.RealEstate.PropertyData pd = null; if (hList != null && hList.Count > 0) { foreach (Household h in hList) { pd = h.RealEstateManager.FindProperty(lot); if (pd != null && pd.Owner != null) { lotOwner = pd.Owner.OwningHousehold; break; } } } } } return(lotOwner); }
public void UpdateTheatre(Theatre theatre) { using (UserContext context = new UserContext()) { context.Entry(theatre).State = EntityState.Modified; //Updating theatre details in database context.SaveChanges(); } }
public Theatre GetTheatreById(int theatreId) //Method for get theatre id { using (UserContext theatreContext = new UserContext()) { Theatre theatre = theatreContext.Theatres.Where(model => model.TheatreId == theatreId).SingleOrDefault(); return(theatre); } }
public string GetStatus(int userId) //method for getting the theatre status { using (UserContext userContext = new UserContext()) { Theatre theatre = userContext.Theatres.Where(model => model.UserId == userId).SingleOrDefault(); return(theatre.Status); } }
public IEnumerable <PlayDTO> GetPlays(int theatreId) { Theatre theatre = Database.TheatresRepository.FindById(theatreId); var mapper = new MapperConfiguration(cfg => cfg.CreateMap <Play, PlayDTO>()).CreateMapper(); return(mapper.Map <IEnumerable <Play>, List <PlayDTO> >(theatre.Plays)); }
public Theatre GetData(int id) { using (UserContext theatreContext = new UserContext()) { Theatre theatre = theatreContext.Theatres.Where(model => model.UserId == id).SingleOrDefault(); return(theatre); } }
public addEditPerformances(Theatre theatre) { InitializeComponent(); deleteButton.IsEnabled = false; isEditMode = false; id = ""; thisTheatre = theatre; }
public ActionResult DeleteConfirmed(int id) { Theatre theatre = db.Theatres.Find(id); db.Theatres.Remove(theatre); db.SaveChanges(); return(RedirectToAction("Index")); }
public async Task <Theatre> Delete(int id) { Theatre existing = await _theatreContext.Theatres.FindAsync(id); var result = _theatreContext.Theatres.Remove(existing); return(result.Entity); }
public Theatre DisplayTheatre(int theatreId) { using (UserContext userContext = new UserContext()) { Theatre theatre = userContext.Theatres.Where(model => model.TheatreId == theatreId).SingleOrDefault(); return(theatre); } }
public void SignUpNext(Theatre theatre) //Method for sign up next { using (UserContext userContext = new UserContext()) { userContext.Theatres.Add(theatre); userContext.SaveChanges(); } }
public Show(Theatre theatre) { this(); for (int i = 0, len = theatre.numberOfSeats; i < len; ++i) { /* Code to add to list */ } }
public static void FulfillWant(Sim sim, Theatre theater) { EventTracker.SendEvent(new AttendedShowEvent(Sims3.Gameplay.Abstracts.ShowVenue.ShowTypes.kMovie, sim)); EventTracker.SendEvent(EventTypeId.kReceivedRabbitHoleTreatment, sim, theater); }
protected override void ExecuteInsertPerformanceCommand(string[] commandWords) { var venue = this.GetVenue(commandWords[5]); switch (commandWords[2]) { case "movie": var movie = new Movie( commandWords[3], decimal.Parse(commandWords[4]), venue, DateTime.Parse(commandWords[6] + " " + commandWords[7])); this.Performances.Add(movie); break; case "theatre": var theatre = new Theatre( commandWords[3], decimal.Parse(commandWords[4]), venue, DateTime.Parse(commandWords[6] + " " + commandWords[7])); this.Performances.Add(theatre); break; case "concert": var concert = new Concert( commandWords[3], decimal.Parse(commandWords[4]), venue, DateTime.Parse(commandWords[6] + " " + commandWords[7])); this.Performances.Add(concert); break; default: break; } }
protected override void ExecuteInsertPerformanceCommand(string[] commandWords) { string venueName = commandWords[5]; DateTime dateTime = DateTime.Parse(commandWords[6] + " " + commandWords[7]); string name = commandWords[3]; decimal price = decimal.Parse(commandWords[4]); var venue = this.GetVenue(venueName); switch (commandWords[2]) { case "theatre": var theatre = new Theatre(name, price, venue, dateTime); this.Performances.Add(theatre); break; case "concert": var concert = new Concert(name, price, venue, dateTime); this.Performances.Add(concert); break; default: base.ExecuteInsertPerformanceCommand(commandWords); break; } }
public static TheatreViewModel Map(TheatreViewModel viewModel, Theatre entity) { return Mapper.Map(entity, viewModel); }
public void AddListing(int ownerId, EditListingViewModel model) { using (var session = NHibernateHelper.OpenSession()) { using (var transaction = session.BeginTransaction()) { // get existing entities var owner = session.CreateCriteria(typeof (Owner)) .List<Owner>().FirstOrDefault(x => x.Id.Equals(ownerId)); var categoryId = model.CategoryId; if (categoryId==0) int.TryParse(model.Category, out categoryId); var category = session.CreateCriteria(typeof(Category)) .List<Category>().FirstOrDefault(x => x.Id.Equals(categoryId)); var packageId = model.PackageId; if (packageId == 0) int.TryParse(model.Package, out packageId); var package = session.CreateCriteria(typeof(PaymentPackage)) .List<PaymentPackage>().FirstOrDefault(x => x.Id.Equals(packageId)); var addressDetailKey = CustomStringHelper.BuildKey(new[] { model.Address1, model.Postcode }); // if (!string.IsNullOrEmpty(model.ListingKey)) // { // addressDetailKey = model.ListingKey; // } // get potentially new entities and save them // address var address = session.CreateCriteria(typeof(AddressDetail)) .List<AddressDetail>().FirstOrDefault(x => x.AddressDetailKey.Equals(addressDetailKey)) ?? new AddressDetail(); address.Address1 = model.Address1; address.Address2 = model.Address2; address.Town = model.Town; address.Postcode = model.Postcode.ToUpperInvariant(); address.IsActive = 1; address.AddressDetailKey = CustomStringHelper.BuildKey(new[] { model.Address1, model.Postcode }); addressDetailKey = address.AddressDetailKey; SetAudit(address); session.SaveOrUpdate(address); // contact var contactDetail = session.CreateCriteria(typeof(ContactDetail)) .List<ContactDetail>().FirstOrDefault(x => x.ContactDetailKey.Equals(owner.OwnerKey)) ?? new ContactDetail(); contactDetail.Website = model.WebsiteUrl; contactDetail.IsActive = 1; contactDetail.ContactDetailKey = owner.OwnerKey; SetAudit(contactDetail); session.SaveOrUpdate(contactDetail); // location var location = session.CreateCriteria(typeof(Location)) .List<Location>().FirstOrDefault(x => x.Postcode.Equals(model.Postcode)) ?? new Location(); // get geolocation from postcode decimal lat = 0; decimal lng = 0; try { var requestUri = string.Format("http://maps.googleapis.com/maps/api/geocode/xml?address={0}&sensor=false", Uri.EscapeDataString(model.Postcode)); var request = WebRequest.Create(requestUri); var response = request.GetResponse(); var xdoc = XDocument.Load(response.GetResponseStream()); decimal.TryParse(xdoc.XPathSelectElement("GeocodeResponse/result/geometry/location/lat").Value, out lat); decimal.TryParse(xdoc.XPathSelectElement("GeocodeResponse/result/geometry/location/lng").Value, out lng); } catch{ } location.Postcode = model.Postcode.ToUpperInvariant(); location.Latitude = lat; location.Longitude = lng; location.IsActive = 1; SetAudit(location); session.SaveOrUpdate(location); //if (!string.IsNullOrEmpty(model.ListingKey)) //{ // addressDetailKey = model.ListingKey; //} // listing var listing = session.CreateCriteria(typeof(ListingDetail)) .List<ListingDetail>().FirstOrDefault(x => x.ListingKey.Equals(addressDetailKey)) ?? new ListingDetail(); listing.Init(); listing.ExpiraryDate = DateTime.Now; listing.Description = package==null || package.Id == 1 ? model.Description : model.DescriptionHtml; listing.StrapLine = model.StrapLine; listing.Price = model.Price; listing.AddressDetail = address; listing.Owner = owner; listing.PaymentPackage = package; listing.Category = category; listing.Location = location; listing.Notes = model.Notes; listing.ListingKey = CustomStringHelper.BuildKey(new[] { model.Address1, model.Postcode });; listing.Notes = model.Notes; SetAudit(listing); listing.IsActive = 1; session.SaveOrUpdate(listing); // rooms DeleteRooms(session, listing.Id); if (!string.IsNullOrEmpty(model.Rooms)) { var rooms = JsonConvert.DeserializeObject<List<RoomViewModel>>(model.Rooms); foreach (var roomViewModel in rooms) { var room = new Room {Description = roomViewModel.Description, Type = roomViewModel.RoomType}; room.ListingDetail = listing; SetAudit(room); room.IsActive = 1; session.SaveOrUpdate(room); listing.Rooms.Add(room); } } // theatres DeleteTheatres(session, listing.Id); if (!string.IsNullOrEmpty(model.Theatres)) { var theatres = JsonConvert.DeserializeObject<List<TheatreViewModel>>(model.Theatres); foreach (var theatreViewModel in theatres) { var theatre = new Theatre { Name = theatreViewModel.Name, Town = theatreViewModel.Town, Distance = theatreViewModel.Distance, Transport = theatreViewModel.Transport, ListingDetail = listing }; SetAudit(theatre); theatre.IsActive = 1; session.SaveOrUpdate(theatre); listing.Theatres.Add(theatre); } } // images DeleteImages(session, listing.Id); if (!string.IsNullOrEmpty(model.Images)) { var images = JsonConvert.DeserializeObject<List<ImageViewModel>>(model.Images); foreach (var imageViewModel in images) { var image = new Image { Alt = "Owner Image", ThumbUrl = imageViewModel.File, LargeUrl = imageViewModel.File.Replace("thumbnails/", ""), DisplayOrder = images.IndexOf(imageViewModel), ListingDetail = listing }; SetAudit(image); image.IsActive = 1; session.SaveOrUpdate(image); listing.Images.Add(image); } } // tags DeleteTags(session, listing.Id); if (!string.IsNullOrEmpty(model.Tags)) { var taglist = model.Tags.Split(','); foreach (var strTag in taglist) { var tag = new Tag {Name = strTag}; SetAudit(tag); tag.ListingDetail = listing; tag.IsActive = 1; session.SaveOrUpdate(tag); listing.Tags.Add(tag); } } SetAudit(listing); listing.IsActive = 1; session.SaveOrUpdate(listing); transaction.Commit(); } } }