void Submit_Click(object sender, EventArgs e) { try { BusinessObjectLayer.Port port = new Port() { Name = this.Name.Text.Trim(), Country = this.Country.Text.Trim() }; DataAccessLayer.Port dalPort = new DataAccessLayer.Port(); if (dalPort.GetAllBy(new List<SearchParameter>() {new SearchParameter("Name", port.Name)}).Count > 0) { throw new Exception("Er is al een bestemming met deze naam."); } dalPort.Insert(port); this.SetFlash("Bestemming succesvol toegevoegd."); } catch (Exception ex) { this.SetFlash("Er is iets misgegaan. Probeer het nogmaals a.u.b.. (Fout: " + ex.Message + ")", FlashType.Danger); this.Response.Redirect(this.Request.RawUrl); } this.Response.RedirectPermanent("?page=Destination"); }
/// <summary> /// The page_ load. /// </summary> /// <param name="sender"> /// The sender. /// </param> /// <param name="e"> /// The e. /// </param> protected void Page_Load(object sender, EventArgs e) { List<Ship> ships = new DataAccessLayer.Ship().GetAll(); this.DropDownShip.Items.Clear(); ships.ForEach(x => this.DropDownShip.Items.Add(new ListItem(x.Name, x.Id.ToString()))); if (this.Ship != null) { this.DropDownShip.Items.FindByValue(this.Ship.Id.ToString()).Selected = true; } List<Port> ports = new DataAccessLayer.Port().GetAll(); this.DropDownPort.Items.Clear(); ports.ForEach(x => this.DropDownPort.Items.Add(new ListItem(x.ToString(), x.Id.ToString()))); if (this.Port != null) { this.DropDownPort.Items.FindByValue(this.Port.Id.ToString()).Selected = true; } this.Submit.Click += this.Submit_Click; this.Export.Click += this.Export_Click; }