public void TestMethodCreate() { int countBeforeCreate = this.dalCustomer.GetAll().Count; int countAfterCreate; this.customer = new BusinessObjectLayer.Customer(); this.customer.Password = "******"; this.customer.Phone = "0641090900"; this.customer.Email = "*****@*****.**"; this.customer.CellPhone = "049222222222"; this.dalCustomer.Insert(this.customer); countAfterCreate = this.dalCustomer.GetAll().Count; Assert.IsTrue(countAfterCreate - 1 == countBeforeCreate); }
/// <summary> /// The submit_ click. /// </summary> /// <param name="sender"> /// The sender. /// </param> /// <param name="e"> /// The e. /// </param> /// <exception cref="Exception"> /// </exception> private void Submit_Click(object sender, EventArgs e) { int customerId = 0; if (this.AuthorizedFor == AccessLevel.Private) { int.TryParse(this.Customer.SelectedValue, out customerId); } try { if (customerId > 0 && this.dalCustomer.GetBy(new SearchParameter("Id", customerId)) == null) { throw new Exception("Bedrijf niet gevonden."); } if (this.dalCustomer.GetBy(new SearchParameter("CoC", this.Coc.Text.Trim())) != null) { throw new Exception("Bedrijf staat al geregistreerd in onze database."); } if (this.dalCustomer.GetBy(new SearchParameter("Username", this.Username.Text.Trim())) != null) { throw new Exception("Gebruikersnaam staat al geregistreerd in onze database."); } var customer = new BusinessObjectLayer.Customer { Username = this.AuthorizedFor == AccessLevel.Private ? this.Username.Text.Trim() : base.Username, Name = this.Name.Text.Trim(), CompanyName = this.Companyname.Text.Trim(), CoC = this.Coc.Text.Trim() }; if (customerId > 0) { customer.CustomerId = customerId; } this.dalCustomer.Insert(customer); } catch (Exception ex) { this.SetFlash( "Er is een fout opgetreden bij het aanmaken, probeer het nogmaals a.u.b.. (Fout: " + ex.Message + ")", FlashType.Danger); this.Response.Redirect(this.Request.RawUrl); } if (this.AuthorizedFor == AccessLevel.Private) { this.SetFlash("Gebruikersaccount is succesvol toegevoegd."); this.Response.Redirect("?page=Customer&method=List"); } else { this.SetFlash("U bent succesvol geregistreerd, u wordt nu automatisch aangemeld."); this.Response.Redirect("/"); } }