public void save_Click(object sender, EventArgs e) { TransitPlaceWebsite tw = new TransitPlaceWebsite(); tw.Name = inputName.Text; if (string.IsNullOrEmpty(inputUrl.Text) || inputUrl.Text == "http://") throw new Exception("Missing url"); if (!Uri.IsWellFormedUriString(inputUrl.Text, UriKind.Absolute)) inputUrl.Text = "http://" + inputUrl.Text; if (string.IsNullOrEmpty(inputName.Text)) throw new Exception("Missing title"); tw.Url = inputUrl.Text; tw.Description = inputDescription.Text; tw.Id = RequestId; tw.PlaceId = PlaceId; TransitPlaceWebsite t_existing = SessionManager.GetInstance<TransitPlaceWebsite, int, string>( PlaceId, tw.Url, SessionManager.PlaceService.GetPlaceWebsiteByUri); if (t_existing != null && t_existing.Id != RequestId) { throw new Exception(string.Format("The website \"{0}\" has already been added.", tw.Url)); } SessionManager.CreateOrUpdate<TransitPlaceWebsite>( tw, SessionManager.PlaceService.CreateOrUpdatePlaceWebsite); Redirect(string.Format("PlaceView.aspx?id={0}", tw.PlaceId)); }
public override TransitPicture GetPictureWithThumbnail(int id) { TransitPlaceWebsite p = SessionManager.GetInstance <TransitPlaceWebsite, int>( id, SessionManager.PlaceService.GetPlaceWebsiteById); if (p == null || p.Bitmap == null) { return(GetRandomPictureWithThumbnail()); } TransitPicture result = new TransitPicture(); result.Id = p.Id; result.Bitmap = p.Thumbnail; result.Created = p.Created; result.Modified = p.Modified; result.Name = p.Name; return(result); }
public void CreatePlaceWebsiteInvalid() { ManagedAccount a = new ManagedAccount(Session); try { a.Create("Test User", "testpassword", "*****@*****.**", DateTime.UtcNow, AdminSecurityContext); TransitPlaceWebsite ta = new TransitPlaceWebsite(); ta.Name = "My Website"; ta.Description = "Lots of details."; ta.Url = "<script>attack!</script>"; ta.PlaceId = _place.Instance.Id; ManagedPlaceWebsite m_w = new ManagedPlaceWebsite(Session); m_w.CreateOrUpdate(ta, a.GetSecurityContext()); } finally { a.Delete(AdminSecurityContext); } }
public void save_Click(object sender, EventArgs e) { TransitPlaceWebsite tw = new TransitPlaceWebsite(); tw.Name = inputName.Text; if (string.IsNullOrEmpty(inputUrl.Text) || inputUrl.Text == "http://") { throw new Exception("Missing url"); } if (!Uri.IsWellFormedUriString(inputUrl.Text, UriKind.Absolute)) { inputUrl.Text = "http://" + inputUrl.Text; } if (string.IsNullOrEmpty(inputName.Text)) { throw new Exception("Missing title"); } tw.Url = inputUrl.Text; tw.Description = inputDescription.Text; tw.Id = RequestId; tw.PlaceId = PlaceId; TransitPlaceWebsite t_existing = SessionManager.GetInstance <TransitPlaceWebsite, int, string>( PlaceId, tw.Url, SessionManager.PlaceService.GetPlaceWebsiteByUri); if (t_existing != null && t_existing.Id != RequestId) { throw new Exception(string.Format("The website \"{0}\" has already been added.", tw.Url)); } SessionManager.CreateOrUpdate <TransitPlaceWebsite>( tw, SessionManager.PlaceService.CreateOrUpdatePlaceWebsite); Redirect(string.Format("PlaceView.aspx?id={0}", tw.PlaceId)); }
public void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { SiteMapDataAttribute sitemapdata = new SiteMapDataAttribute(); sitemapdata.Add(new SiteMapDataAttributeNode("Places", Request, "PlacesView.aspx")); TransitPlace place = SessionManager.GetInstance <TransitPlace, int>( PlaceId, SessionManager.PlaceService.GetPlaceById); sitemapdata.Add(new SiteMapDataAttributeNode(place.Name, Request, string.Format("PlaceView.aspx?id={0}", place.Id))); linkBack.NavigateUrl = string.Format("PlaceView.aspx?id={0}", place.Id); DomainClass cs = SessionManager.GetDomainClass("PlaceWebsite"); inputName.MaxLength = cs["Name"].MaxLengthInChars; inputUrl.MaxLength = cs["Url"].MaxLengthInChars; if (RequestId > 0) { TransitPlaceWebsite tw = SessionManager.GetInstance <TransitPlaceWebsite, int>( RequestId, SessionManager.PlaceService.GetPlaceWebsiteById); inputName.Text = tw.Name; inputUrl.Text = tw.Url; inputDescription.Text = tw.Description; sitemapdata.Add(new SiteMapDataAttributeNode(tw.Name, Request.Url)); } else { sitemapdata.Add(new SiteMapDataAttributeNode("Link a Site", Request.Url)); } StackSiteMap(sitemapdata); } SetDefaultButton(manageAdd); }
public void save_Click(object sender, EventArgs e) { TransitPlace t = new TransitPlace(); t.Name = inputName.Text; t.Type = selectType.SelectedValue; t.Id = RequestId; t.Description = inputDescription.Text; t.CrossStreet = inputCrossStreet.Text; t.Email = inputEmail.Text; t.Fax = inputFax.Text; t.Phone = inputPhone.Text; t.Street = inputStreet.Text; t.Zip = inputZip.Text; t.City = inputCity.Text; t.Neighborhood = inputNeighborhood.Text; t.State = inputState.SelectedValue; t.Country = inputCountry.SelectedValue; if (string.IsNullOrEmpty(t.Name)) { throw new Exception("Please enter a name."); } if (string.IsNullOrEmpty(t.City)) { throw new Exception("Please enter a city."); } if (string.IsNullOrEmpty(t.Country)) { throw new Exception("Please enter a country."); } int place_id = SessionManager.CreateOrUpdate <TransitPlace>( t, SessionManager.PlaceService.CreateOrUpdatePlace); ppg.PlaceId = place_id; ppg.save_Click(sender, e); try { string website = inputWebsite.Text; if (RequestId == 0 && !string.IsNullOrEmpty(website) && website != "http://") { if (!website.StartsWith("http://")) { website = website.Insert(0, "http://"); } TransitPlaceWebsite t_website = new TransitPlaceWebsite(); t_website.AccountId = SessionManager.AccountId; t_website.Name = t.Name; t_website.PlaceId = place_id; t_website.Url = website; t_website.Id = SessionManager.CreateOrUpdate <TransitPlaceWebsite>( t_website, SessionManager.PlaceService.CreateOrUpdatePlaceWebsite); } } catch (UriFormatException) { } Redirect(string.Format("PlaceView.aspx?id={0}", place_id)); }
public int CreateOrUpdatePlaceWebsite(string ticket, TransitPlaceWebsite t_instance) { return WebServiceImpl<TransitPlaceWebsite, ManagedPlaceWebsite, PlaceWebsite>.CreateOrUpdate( ticket, t_instance); }
public void save_Click(object sender, EventArgs e) { TransitPlace t = new TransitPlace(); t.Name = inputName.Text; t.Type = selectType.SelectedValue; t.Id = RequestId; t.Description = inputDescription.Text; t.CrossStreet = inputCrossStreet.Text; t.Email = inputEmail.Text; t.Fax = inputFax.Text; t.Phone = inputPhone.Text; t.Street = inputStreet.Text; t.Zip = inputZip.Text; t.City = inputCity.Text; t.Neighborhood = inputNeighborhood.Text; t.State = inputState.SelectedValue; t.Country = inputCountry.SelectedValue; if (string.IsNullOrEmpty(t.Name)) throw new Exception("Please enter a name."); if (string.IsNullOrEmpty(t.City)) throw new Exception("Please enter a city."); if (string.IsNullOrEmpty(t.Country)) throw new Exception("Please enter a country."); int place_id = SessionManager.CreateOrUpdate<TransitPlace>( t, SessionManager.PlaceService.CreateOrUpdatePlace); ppg.PlaceId = place_id; ppg.save_Click(sender, e); try { string website = inputWebsite.Text; if (RequestId == 0 && !string.IsNullOrEmpty(website) && website != "http://") { if (!website.StartsWith("http://")) website = website.Insert(0, "http://"); TransitPlaceWebsite t_website = new TransitPlaceWebsite(); t_website.AccountId = SessionManager.AccountId; t_website.Name = t.Name; t_website.PlaceId = place_id; t_website.Url = website; t_website.Id = SessionManager.CreateOrUpdate<TransitPlaceWebsite>( t_website, SessionManager.PlaceService.CreateOrUpdatePlaceWebsite); } } catch (UriFormatException) { } Redirect(string.Format("PlaceView.aspx?id={0}", place_id)); }