public void CanAddVenue() { Guid id = new Guid(); string name = "NightnDay"; string url = "http://www.nightnday.org/"; string description = "The heart and soul of Manchesters music scene."; string telephone = "0161 236 4597"; Town town = new Town(); Venue venue = new Venue(); venue.ID = id; venue.Name = name; venue.Description = description; venue.URL = url; venue.Telephone = telephone; venue.Town = town; Assert.That(venue.ID, Is.EqualTo(id)); Assert.That(venue.Name, Is.EqualTo(name)); Assert.That(venue.Description, Is.EqualTo(description)); Assert.That(venue.Town, Is.EqualTo(town)); Assert.That(venue.URL, Is.EqualTo(url)); Assert.That(venue.Town, Is.EqualTo(town)); }
public string ViewVenueUrl(Venue venue) { return UrlHelper.RouteUrl("venue", new { venueId = venue.ID }); }
public object BindModel(ControllerContext controllerContext, ModelBindingContext bindingContext) { HttpRequestBase request = controllerContext.HttpContext.Request; Gig gig = null; if (bindingContext.Model == null) { gig = new Gig(); gig.ID = Guid.NewGuid(); } else { gig = (Gig)bindingContext.Model; } gig.Name = ModelBinderHelpers.GetValueAndUpdateModelState<string>(bindingContext, "Name"); gig.Description = ModelBinderHelpers.GetValueAndUpdateModelState<string>(bindingContext, "Description"); int day = ModelBinderHelpers.GetValueAndUpdateModelState<int>(bindingContext, "day"); int month = ModelBinderHelpers.GetValueAndUpdateModelState<int>(bindingContext, "month"); int year = ModelBinderHelpers.GetValueAndUpdateModelState<int>(bindingContext, "year"); int hour = ModelBinderHelpers.GetValueAndUpdateModelState<int>(bindingContext, "hour"); ; int minute = ModelBinderHelpers.GetValueAndUpdateModelState<int>(bindingContext, "minute"); if (ModelBinderHelpers.GetValueAndUpdateModelState<string>(bindingContext, "amPm") == "pm") { hour = hour + 12; } DateTime startDateTime = new DateTime(year, month, day,hour,minute,0); gig.Created = DateTime.Now; gig.StartDate = startDateTime; Guid? venueId = ModelBinderHelpers.GetValueAndUpdateModelState<Guid?>(bindingContext, "SelectedVenue"); Venue venue = null; string venueName = ModelBinderHelpers.GetValueAndUpdateModelState<string>(bindingContext, "VenueName"); if (venueId.HasValue && venueId.Value != Guid.Empty && venueName != string.Empty) { //The use has filled in both the venueName and selected a venue DOH! //Show an error message bindingContext.ModelState.AddModelBinderValidationError("SelectedVenue", ModelBinderValidationStateKeys.CANNOT_SPECIFY_VENUE_ID_AND_VENUE_NAME); } else if (venueId.HasValue && venueId.Value!=Guid.Empty) { venue = VenueManager.GetByID(venueId.Value); gig.Venue = venue; } else if (venueName!=string.Empty) { venue = new Venue(); venue.ID = Guid.NewGuid(); venue.Name = venueName; //Set to Manchester by default. //This will have to change before we open up to different cities venue.Town = TownManager.GetByID(new Guid("0D5A3A81-53C1-48B0-B176-A419ACBB2EE8")); gig.Venue = venue; } //Artist Ids string[] bandNames = ModelBinderHelpers.GetValueAndUpdateModelState<string>(bindingContext, "ActNames").Split(new char[] { ',' }); string[] bandIds = ModelBinderHelpers.GetValueAndUpdateModelState<string>(bindingContext, "ArtistIds").Split(new char[] { ';' }); gig.Acts = new List<Act>(); Guid currentID; Artist currentArtist; bool exists = false; //Add the Artists that were explicitly selected to the acts collection foreach(string id in bandIds){ if (ListenTo.Shared.Utility.Is.GUID(id)) { currentID = new Guid(id); exists = ((List < Act > )gig.Acts).Exists(delegate(Act a) { return a.Artist.ID == currentID; }); if(!exists) { currentArtist = ArtistManager.GetByID(currentID); //Ensure that the bandNames and bandIds are synchronised.... if (bandNames.Contains<string>(currentArtist.Name)) { AddActToGig(gig, currentArtist,null); } } } } //Add the unknown bands to the acts collection foreach (string bandName in bandNames) { if (bandName!= null && bandName != string.Empty && bandName.Trim().Length!=0) { exists = ((List<Act>)gig.Acts).Exists(delegate(Act a) { return a.Name == bandName; }); if (!exists) { AddActToGig(gig, null, bandName); } } } string ticketPrice = ModelBinderHelpers.GetValueAndUpdateModelState<string>(bindingContext, "ticketPrice"); gig.TicketPrice = ticketPrice; OwnershipHelpers.SetOwner((IOwnableDO)gig, controllerContext.HttpContext.User); return gig; }
public static string ViewVenueUrl(this HtmlHelper helper, Venue venue) { return IOCHelper.GetRouteHelpers().ViewVenueUrl(venue); }