public ResourceResult Post(EditVenueUrl url, VenueViewModel input) { var result = new VenueMetadata { Id = input.Id, VenueName = url.VenueName, MainImageName = input.MainImage == null ? input.MainImageName : url.VenueName + "." + input.MainImage.FileName.Split('.').Last(), BarAndClubReviewsUrl = input.BarAndClubReviewsUrl.EnsureHttp(), ContactDetail = new ContactDetail { EmailAddress = input.EmailAddress, MainPhoneNumber = input.MainPhoneNumber, PostCode = input.PostCode, Website = input.Website.EnsureHttp(), AddressLines = input.AddressLines ?? new string[] { }, ContactName = input.ContactName, SecondaryPhoneNumbers = input.SecondaryPhoneNumbers ?? new string[] { } }, MapCoords = new GoogleMapCoords { Lat = input.Lat, Long = input.Long } }; metadata.Store(result, input.MainImage); return SeeOther(new VenuesUrl()); }
public ResourceResult Get(EditVenueUrl url) { var metadata = venues.GetMetadata(new VenueName { Value = url.VenueName }); return OK(new VenueViewModel { Name = new VenueName { Value = url.VenueName }, BarAndClubReviewsUrl = metadata.BarAndClubReviewsUrl, AddressLines = metadata.ContactDetail.AddressLines, ContactName = metadata.ContactDetail.ContactName, EmailAddress = metadata.ContactDetail.EmailAddress, Website = metadata.ContactDetail.Website, Id = metadata.Id, Lat = metadata.MapCoords.Lat, Long = metadata.MapCoords.Long, MainImageName = metadata.MainImageName, MainPhoneNumber = metadata.ContactDetail.MainPhoneNumber, PostCode = metadata.ContactDetail.PostCode, SecondaryPhoneNumbers = metadata.ContactDetail.SecondaryPhoneNumbers, Gigs = venues.Get(new VenueName { Value = url.VenueName }).Gigs }).AsHtml(); }