public void AddCustomer_CustomerHasMultipleMainAddresses_Returns400Response() { // Arrange var address = new AddressModel() { IsMainAddress = true }; var addresses = new List <AddressModel>() { address, address }; // Act var result = controller.AddCustomer(new CustomerModel() { Addresses = addresses }) as BadRequestObjectResult; // Assert result.Should().NotBeNull(); result.StatusCode.Should().Be(400); var message = result.Value as string; message.Should().NotBeNullOrEmpty(); message.Should().Contain("Customer has multiple main addresses"); }
public void AddCustomer_UnitOfWorkAcceptsModel_UutReturnsCreatedWithRouteAndObject() { var result = uut.AddCustomer(defaultCustomerDto); var resultObj = result as CreatedResult; Assert.That(result, Is.TypeOf <CreatedResult>()); Assert.That(resultObj.Location, Is.EqualTo($"api/Customer/{defaultCustomerDto.Username}")); Assert.That(resultObj.Value, Is.TypeOf <CustomerDto>()); }
public void DuplicateInsertTestMethod() { CustomerController customerController = new CustomerController(); bool result = customerController.AddCustomer(ExpectedMethod6); if (result) { result = customerController.AddCustomer(ExpectedMethod6); } Assert.AreEqual(false, result); }
public void Add_WhenCalled_ReturnsOk() { var customer = new Customer { Id = "1", Name = "Onur", Email = "*****@*****.**" }; var result = customerController.AddCustomer(customer); Assert.IsType <OkObjectResult>(result); }
private void btnSubmit_Click(object sender, EventArgs e) { Model.Customer newCustomer = new Model.Customer(); newCustomer.FirstName = txtFirstName.Text; newCustomer.LastName = txtLastName.Text; newCustomer.Address = txtAddress.Text; newCustomer.Phone = txtPhone.Text; newCustomer.DateOfBirth = dtDob.Text; if (newCustomer.FirstName == "" || newCustomer.LastName == "") { lblMessage.Text = "Please Enter Customer name"; return; } bool result = customerController.AddCustomer(newCustomer); if (result) { lblMessage.Text = String.Format("Customer {0} {1} is registerd.", newCustomer.FirstName, newCustomer.LastName); UpdateCustomerGrid(); } else { lblMessage.Text = "Somethings goes wrong"; } }
public void AddCustomer_InvalidInputId_ReturnsBadRequestObject() { //Arrange var customer = new Customer() { Name = "TestCustomer" }; _controller.ModelState.AddModelError("Id", "Id is required"); //Act var result = _controller.AddCustomer(customer); //Assert Assert.IsType <BadRequestObjectResult>(result); }
public async Task AddCustomerTest() { //Given // Generate a database names AddCustomerTest in mem var dbContext = DbContextMock.getDataContext(nameof(AddCustomerTest)); // get a repo var _repo = new CustomerRepository(dbContext); var controller = new CustomerController(_repo, _mapper); // customer to Add var createdCustomer = new CustomerForCreationDTO() { CustomerType = 1, FirstName = "Johannes", LastName = "Bach", EmailAddress = "*****@*****.**" }; //When var result = await controller.AddCustomer(createdCustomer) as ObjectResult; var customerFromRepo = await _repo.getCustomer(4); // Dispose context dbContext.Dispose(); //Then Assert.Equal(201, result.StatusCode); Assert.Equal(createdCustomer.FirstName, customerFromRepo.FirstName); }
private async void btnAdd_Click(object sender, EventArgs e) { btnAdd.Enabled = false; btnBack.Enabled = false; if (ValidateData()) { CustomerModel customer = new CustomerModel(customerID, txtNome.Text, txtContacto.Text, txtEndereco.Text, txtEmail.Text, txtNascimento.Value, txtCategoria.Text, DateTime.Now, "userROOT", 1); if (isUpdateCustomer) { if (await Controller.UpdateCustomerModels(customer)) { ClearData(); MessageBox.Show("Cliente " + customer.Name + " Atualizado com sucesso", "Vissoka", MessageBoxButtons.OK, MessageBoxIcon.Information); dgvClientes.CurrentRow.Cells[1].Value = customer.Name; dgvClientes.CurrentRow.Cells[2].Value = customer.Contacts; dgvClientes.CurrentRow.Cells[3].Value = customer.Email; dgvClientes.CurrentRow.Cells[4].Value = customer.Address; tabControl1.SelectTab(tabAdd); isUpdateCustomer = false; customerID = 0; } else { MessageBox.Show("O cliente não pode ser Atualizado, tente novamente mais tarde", "Vissoka", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } } else { int new_customer = await Controller.AddCustomer(customer); if (new_customer > 0) { customer = new CustomerModel(new_customer, txtNome.Text, txtContacto.Text, txtEndereco.Text, txtEmail.Text, txtNascimento.Value, txtCategoria.Text, DateTime.Now, "userROOT", 1); if (dgvClientes.Rows.Count == 0) { await GetCustumers(); } else { customers.Add(customer); dgvClientes.Rows.Add(customer.ID, customer.Name, customer.Contacts, customer.Address, customer.Email, customer.Data_Nascimento); } ClearData(); MessageBox.Show("Cliente Cadastrado com sucesso", "Vissoka", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { MessageBox.Show("O cliente não pode ser cadastrado, tente novamente mais tarde", "Vissoka", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } } } btnAdd.Enabled = true; btnBack.Enabled = true; }
public void AddCustomer_WithInvalidCustomerDetails_ShouldThrowException() { Assert.ThrowsException<ArgumentException>(() => _controller.AddCustomer(null), "AddCustomer_InvalidArguments"); Assert.ThrowsException<ArgumentException>(() => _controller.AddCustomer(new CustomerDetails()), "AddCustomer_InvalidArguments"); Assert.ThrowsException<ArgumentException>(() => _controller.AddCustomer(new CustomerDetails {email = ""}), "AddCustomer_InvalidArguments"); Assert.ThrowsException<ArgumentException>(() => _controller.AddCustomer(new CustomerDetails { email = "invalidemail" }), "AddCustomer_InvalidEmail"); Assert.ThrowsException<ArgumentException>(() => _controller.AddCustomer(new CustomerDetails { email = "invalidemail@nothing" }), "AddCustomer_InvalidEmail"); }
public void AddRecordToJsonFileTestMethod() { string ExpectedMethod5 = RandName(); CustomerController customerController = new CustomerController(); bool result = customerController.AddCustomer(ExpectedMethod5); Assert.AreEqual(true, result); }
private void button1_Click(object sender, EventArgs e) { bool check = CustomerController.AddCustomer(idlabel.Text, nametext.Text, sdttext.Text, int.Parse(loaiCombobox.SelectedValue.ToString()), int.Parse(gioitinhcbbox.SelectedValue.ToString()), Convert.ToInt32(tuoinumber.Value), diachirichtext.Text, listWithout); if (check == true) { this.DialogResult = DialogResult.OK; } }
public void Add_ValidObjectPassed_ReturnsCreatedResponse() { // Arrange Customer testItem = new Customer() { CustName = "xyz", CustAddress = "abc", CustEmailId = "xyza@abc", CustMobiile = "0000123456", CreatedDate = System.DateTime.Now, UpatedDate = System.DateTime.Now }; // Act var createdResponse = _CustomerController.AddCustomer(testItem); // Assert Assert.IsType <CreatedAtActionResult>(createdResponse); }
public async void AddCustomerPostOKResult() { //Arrange var customerNew = new CustomerModel { Name = "ATHRI", Email = "*****@*****.**", Password = "******" }; var data = await customerController.AddCustomer(customerNew); //Assert Assert.IsType <OkObjectResult>(data); }
public void ReviewAddedFromSameUserTwice_ReturnsBadRequest_ReviewNotChanged() { var barController = new BarController(_uow, _mapper); barController.AddBar(new BarDto() { BarName = "Bar1", AvgRating = 0.0, ShortDescription = "SD", AgeLimit = 18, CVR = 1235, Image = "png.jpg", LongDescription = "short", Address = "123 street", Email = "*****@*****.**", Educations = "IKT", PhoneNumber = 0000, }); var customerController = new CustomerController(_uow, _mapper); customerController.AddCustomer(new CustomerDto { DateOfBirth = DateTime.Now, Email = "*****@*****.**", FavoriteBar = "Bar1", FavoriteDrink = "Øl", Name = "TestKunde", Username = "******", }); var reviewController = new ReviewController(_uow, _mapper); reviewController.AddUserReview(new ReviewDto() { BarName = "Bar1", // Bar added Username = "******", // User added BarPressure = 5, // Rating }); // Add review var result = reviewController.AddUserReview(new ReviewDto() { BarName = "Bar1", Username = "******", BarPressure = 1, }); // Add another from same user var secondBarController = CreateBarController(); var bar = (secondBarController.GetBar("Bar1") as OkObjectResult).Value as BarDto; Assert.That(result, Is.TypeOf <BadRequestResult>()); Assert.That(bar.AvgRating, Is.EqualTo(5)); // Check rating has not changed. }
public void CanAddCustomer() { CustomerRepository custRepo = new CustomerRepository(); CustomerController custControl = CustomerController.GetInstance(); custControl.AddCustomer(); custControl.CurrentCustomer.FirstName = "Jimmi"; custControl.CurrentCustomer.LastName = "Christensen"; custControl.CurrentCustomer.Address = "Bernstorffvej 10"; custControl.CurrentCustomer.PhoneNumber = "28734552"; Assert.AreEqual(custRepo.customerList.Count, 1); }
public void ChangeUserReview_AvgRatingChangedForBar() { var barController = new BarController(_uow, _mapper); barController.AddBar(new BarDto() { BarName = "Bar1", AvgRating = 0.0, ShortDescription = "SD", AgeLimit = 18, CVR = 1235, Image = "png.jpg", LongDescription = "short", Address = "123 street", Email = "*****@*****.**", Educations = "IKT", PhoneNumber = 0000, }); var customerController = new CustomerController(_uow, _mapper); customerController.AddCustomer(new CustomerDto { DateOfBirth = DateTime.Now, Email = "*****@*****.**", FavoriteBar = "Bar1", FavoriteDrink = "Øl", Name = "TestKunde", Username = "******", }); var reviewController = new ReviewController(_uow, _mapper); reviewController.AddUserReview(new ReviewDto() { BarName = "Bar1", // Bar added Username = "******", // User added BarPressure = 5, // Rating }); // Add review reviewController.EditUserReview(new ReviewDto() { BarName = "Bar1", Username = "******", BarPressure = 1, }); // Edit it at a later time. var secondBarController = CreateBarController(); var resultObj = (secondBarController.GetBar("Bar1") as OkObjectResult).Value as BarDto; Assert.That(resultObj.AvgRating, Is.EqualTo(1)); }
/// <summary> /// Saves data for new or edited customer to database. /// </summary> protected void ButtonSave_Click(object sender, EventArgs e) { CustomerController controller = new CustomerController(); ActionServiceReference.Customer customer; if (CustomerId == 0) { customer = new ActionServiceReference.Customer(); } else { customer = controller.GetCustomer(CustomerId); } // Get Company name from page. DetailsViewRow row = DetailsViewCustomer.Rows[1]; TextBox textBox = row.Cells[1].Controls[0] as TextBox; customer.Company = textBox.Text.Trim(); // Get City from page. row = DetailsViewCustomer.Rows[2]; textBox = row.Cells[1].Controls[0] as TextBox; customer.City = textBox.Text.Trim(); // Get Country from page. row = DetailsViewCustomer.Rows[3]; textBox = row.Cells[1].Controls[0] as TextBox; customer.Country = textBox.Text.Trim(); try { if (CustomerId == 0) { controller.AddCustomer(customer); } else { controller.UpdateCustomer(customer); } } catch (ApplicationException ex) { LabelError.Text = ex.Message.Replace(Environment.NewLine, "<br />"); LabelError.Visible = true; return; } // Return to list of customers. Response.Redirect("Customers.aspx"); }
public void Can_AddCustomer() { //Arrange var testCustomer = new Customer { Id = 1006, FirstName = "Richard", LastName = "Amani", DOB = DateTime.Parse("1953.03.03") }; //Act var createdResponse = _controller.AddCustomer(testCustomer); //Assert Assert.IsType <OkResult>(createdResponse); }
public void AddReview_BarHasUpdatedRating_ReviewIsSaved() { var barController = new BarController(_uow, _mapper); barController.AddBar(new BarDto() { BarName = "Bar1", AvgRating = 0.0, ShortDescription = "SD", AgeLimit = 18, CVR = 1235, Image = "png.jpg", LongDescription = "short", Address = "123 street", Email = "*****@*****.**", Educations = "IKT", PhoneNumber = 0000, }); var customerController = new CustomerController(_uow, _mapper); customerController.AddCustomer(new CustomerDto { DateOfBirth = DateTime.Now, Email = "*****@*****.**", FavoriteBar = "Bar1", FavoriteDrink = "Øl", Name = "TestKunde", Username = "******", }); var reviewController = new ReviewController(_uow, _mapper); var reviewResult = reviewController.AddUserReview(new ReviewDto() { BarName = "Bar1", // Bar added Username = "******", // User added BarPressure = 5, // Rating }); var secondBarController = CreateBarController(); var barResult = (secondBarController.GetBar("Bar1") as OkObjectResult) .Value as BarDto; Assert.That(reviewResult, Is.TypeOf <CreatedResult>()); Assert.That(barResult.AvgRating, Is.EqualTo(5)); }
public async Task AddCustomer_ShouldReturnCustomer_GivenCustomer( [Greedy] CustomerController sut, AddCustomerCommand command ) { //Act var actionResult = await sut.AddCustomer(command); //Assert var createdResult = actionResult as CreatedResult; createdResult.Should().NotBeNull(); var customer = createdResult.Value as Core.Handlers.AddCustomer.CustomerDto; customer.Should().NotBeNull(); }
private void AddCustomerButton_Click(object sender, RoutedEventArgs e) { TextBox firstnameTextBox = (TextBox)FindName("firstnameTextBox"); TextBox surnameTextBox = (TextBox)FindName("surnameTextBox"); TextBox titleTextBox = (TextBox)FindName("titleTextBox"); TextBox ageTextBox = (TextBox)FindName("ageTextBox"); TextBox notesTextBox = (TextBox)FindName("notesTextBox"); Customer newCustomer = new Customer(); newCustomer.Firstname = firstnameTextBox.Text; newCustomer.Surname = surnameTextBox.Text; newCustomer.Title = titleTextBox.Text; newCustomer.Age = Convert.ToInt32(ageTextBox.Text); newCustomer.Notes = notesTextBox.Text; customerController.AddCustomer(newCustomer); }
private void btnreg_Click(object sender, EventArgs e) { var customer = new { Name = txtname.Text, UserName = txtusername.Text, Password = txtpassword.Text }; var r = CustomerController.AddCustomer(customer); if (r) { MessageBox.Show("Customer Added"); } else { MessageBox.Show("Customer Not Added"); } }
public void Test_ReturnResponseUser() { var _logger = Mock.Of <ILogger <CustomerController> >(); Datas data = new Datas(); _customerRepository.Setup(c => c.AddCustomer(data.SetCustomerForTest)); _userRepository.Setup(u => u.AddUser(data.SetUserForTest)); _addressRepository.Setup(a => a.AddAddress(data.SetAddressForTest)); _controller = new CustomerController(_customerRepository.Object, _userRepository.Object, _addressRepository.Object, _logger, _configuration.Object); IActionResult result = _controller.AddCustomer(data.SetCustomerRegObjForTest); // Assert.IsType<OkObjectResult>(result); // IActionResult result = _controller.AddAddress(datas.SetAddressForTest); OkObjectResult okObjectResult = result as OkObjectResult; ResponseUser returnResult = okObjectResult.Value as ResponseUser; Assert.Equal(data.SetResponseUserForTest.customerId, returnResult.customerId); Assert.Equal(data.SetResponseUserForTest.token, returnResult.token); }
public async Task AddCustomerIsSuccessful() { var record = new CustomerViewModel() { ContactName = "Theodoros Fasoulas", CompanyName = "Epsilon", City = "Thessaloniki", }; var mockCustomerRepo = new Mock <ICustomerRepository>(); mockCustomerRepo .Setup(x => x.AddCustomerAsync(record)).Returns(Task.FromResult(record)); CustomerController customerController = new CustomerController(mockCustomerRepo.Object); var output = await customerController.AddCustomer(record); var result = output.Result as OkObjectResult; Assert.Equal(record, result.Value); }
private void RegisterClicked(object sender, EventArgs e) { var customer = new { Name = tbName.Text, Id = custId.Text, Gender = tbGender.SelectedItem.ToString(), MobileNo = tbMobile.Text, UserName = tbUser.Text, Password = tbPass.Text }; var result = CustomerController.AddCustomer(customer); if (result) { MessageBox.Show("Customer Added", "Customer Registration", MessageBoxButtons.OK, MessageBoxIcon.None); } else { MessageBox.Show("Could not Add Customer", "Invalid Registration", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
public void Test_InsertCustomerAndReturnOk() { var _logger = Mock.Of <ILogger <CustomerController> >(); Datas data = new Datas(); _customerRepository.Setup(c => c.AddCustomer(data.SetCustomerForTest)); _userRepository.Setup(u => u.AddUser(data.SetUserForTest)); _addressRepository.Setup(a => a.AddAddress(data.SetAddressForTest)); var validApiKey = ""; Action action = () => new Token(_configuration.Object); _configuration .SetupGet(c => c["Jwt:Key"]) .Returns(validApiKey); _controller = new CustomerController(_customerRepository.Object, _userRepository.Object, _addressRepository.Object, _logger, _configuration.Object); IActionResult result = _controller.AddCustomer(data.SetCustomerRegObjForTest); Assert.IsType <OkObjectResult>(result); }
public void AddCustomer(string first, string last, int day, int month, int year) { var c = new Customer { FirstName = first, LastName = last, DateOfBirth = new DateTime(year, month, day) }; _serviceMock.Setup(s => s.AddEditCustomer(c, false)).Returns(new Response <Customer>()); var controller = new CustomerController(_serviceMock.Object); var res = controller.AddCustomer(c); if (!c.IsValid()) { Assert.Equal(typeof(BadRequestObjectResult), res.Result.GetType()); } else { Assert.Equal(typeof(CreatedResult), res.Result.GetType()); } }
protected void GridCustomerView_RowInserting(object sender, DevExpress.Web.Data.ASPxDataInsertingEventArgs e) { CustomerViewModel model = new CustomerViewModel(); model.Adress = e.NewValues["Adress"].ToString(); model.Country = e.NewValues["Country"].ToString(); model.CustomerNr = e.NewValues["CustomerNr"] == null ? 0 : (int)e.NewValues["CustomerNr"]; model.EMail = e.NewValues["EMail"].ToString(); model.FirstName = e.NewValues["FirstName"].ToString(); model.LastName = e.NewValues["LastName"].ToString(); model.MobilePhone = e.NewValues["MobilePhone"].ToString(); model.Phone = e.NewValues["Phone"].ToString(); model.Place = e.NewValues["Place"].ToString(); model.Salutation = e.NewValues["Salutation"].ToString(); model.ZipCode = e.NewValues["ZipCode"].ToString(); controller.AddCustomer(model); e.Cancel = true; GridCustomerView.CancelEdit(); Bind(); }
private void SubClicked(object sender, EventArgs e) { string errMsg = ""; bool hasErr = false; string name = ""; string username = ""; string pass = ""; string rePass = ""; if (!radioButtonAdmin.Checked && !radioButtonEmployee.Checked && !radioButtonCustomer.Checked) { errMsg += "Registration Type required.\n"; hasErr = true; } if (textBoxRName.Text.Equals("")) { errMsg += "Name required.\n"; hasErr = true; } else { name = textBoxRName.Text; } if (textBoxRUsername.Text.Equals("")) { errMsg += "Username required.\n"; hasErr = true; } else { username = textBoxRUsername.Text; } if (textBoxPass.Text.Equals("")) { errMsg += "Password required.\n"; hasErr = true; } else { pass = textBoxPass.Text; } if (textBoxRePass.Text.Equals("")) { errMsg += "Re entering Password required.\n"; hasErr = true; } else { rePass = textBoxRePass.Text; } if (!pass.Equals(rePass)) { errMsg += "Password doesn't match\n"; hasErr = true; } if (!hasErr) { string output = String.Format("Account created: \n \n" + "name: {0} \n" + "username: {1} \n" , name, username); rTRegOutput.Text = output; if (radioButtonEmployee.Checked) { dynamic employee = new { Name = name, Username = username, Password = pass }; var result = EmployeeController.AddEmployee(employee); if (result) { MessageBox.Show("Employee Added"); } else { MessageBox.Show("Employee Not Added"); } } if (radioButtonAdmin.Checked) { dynamic admin = new { Name = name, Username = username, Password = pass }; var result = AdminController.AddAdmin(admin); if (result) { MessageBox.Show("Admin Added"); } else { MessageBox.Show("Admin Not Added"); } } if (radioButtonCustomer.Checked) { dynamic customer = new { Name = name, Username = username, Password = pass }; var result = CustomerController.AddCustomer(customer); if (result) { MessageBox.Show("Customer Added"); } else { MessageBox.Show("Customer Not Added"); } } } else { MessageBox.Show(errMsg); } }
private void button1_Click(object sender, EventArgs e) { if (string.IsNullOrEmpty(name.Text.Trim()) || string.IsNullOrEmpty(number.Text.Trim()) || string.IsNullOrEmpty(balance.Text.Trim()) || gender.SelectedItem == null || division.SelectedItem == null || string.IsNullOrEmpty(zip.Text.Trim()) || string.IsNullOrEmpty(Peddress.Text.Trim()) || string.IsNullOrEmpty(prAddress.Text.Trim()) || string.IsNullOrEmpty(nid.Text.Trim()) || string.IsNullOrEmpty(bcertificate.Text.Trim()) || string.IsNullOrEmpty(email.Text.Trim()) || string.IsNullOrEmpty(username.Text.Trim()) || string.IsNullOrEmpty(password.Text.Trim()) || !termCheck.Checked) { if (string.IsNullOrEmpty(name.Text.Trim())) { namerror.Visible = true; } else { namerror.Visible = false; } if (string.IsNullOrEmpty(number.Text.Trim())) { mobileerror.Visible = true; } else { mobileerror.Visible = false; } if (gender.SelectedItem == null) { gendererror.Visible = true; } else { gendererror.Visible = false; } if (division.SelectedItem == null) { divisionerror.Visible = true; } else { divisionerror.Visible = false; } if (string.IsNullOrEmpty(zip.Text.Trim())) { ziperror.Visible = true; } else { ziperror.Visible = false; } if (string.IsNullOrEmpty(prAddress.Text.Trim())) { prerror.Visible = true; } else { prerror.Visible = false; } if (string.IsNullOrEmpty(Peddress.Text.Trim())) { peerror.Visible = true; } else { peerror.Visible = false; } if (string.IsNullOrEmpty(nid.Text.Trim())) { niderror.Visible = true; } else { niderror.Visible = false; } if (string.IsNullOrEmpty(bcertificate.Text.Trim())) { bcerror.Visible = true; } else { bcerror.Visible = false; } if (string.IsNullOrEmpty(email.Text.Trim())) { emailerror.Visible = true; } else { emailerror.Visible = false; } if (string.IsNullOrEmpty(username.Text.Trim())) { usererror.Visible = true; } else { usererror.Visible = false; } if (string.IsNullOrEmpty(password.Text.Trim())) { passworderror.Visible = true; } else { passworderror.Visible = false; } if (string.IsNullOrEmpty(confirmpass.Text)) { confirmerror.Visible = true; } else { confirmerror.Visible = false; } if (!termCheck.Checked) { termerror.Visible = true; } else { termerror.Visible = false; } if (string.IsNullOrEmpty(balance.Text)) { balanceerror.Visible = true; } else { balanceerror.Visible = false; } MessageBox.Show("Please enter your all Information", "Invalid Information", MessageBoxButtons.OK, MessageBoxIcon.Error); } else if (!confirmpass.Text.Trim().Equals(password.Text.Trim())) { confirmerror.Visible = true; passerror.Visible = true; } else if (email.Text.Trim().Contains(".com") == false) { emailerror.Visible = true; emailmsg.Visible = true; } else if (number.Text.Trim().Length != 11) { mobileerror.Visible = true; mobilemsg.Visible = true; mobilemsg.Text = String.Format("Enter at 11 digit phone number you enter {0} digits", number.Text.Trim().Length); } else if (number.Text.Trim().Substring(0, 2) != ("01")) { mobileerror.Visible = true; mobilemsg.Visible = true; mobilemsg.Text = String.Format("Wrong operator"); } else if (password.Text.Trim().Length < 6) { passworderror.Visible = true; } else if (Convert.ToInt32(balance.Text) < 500) { balanceerror.Visible = true; } else { try { var customer = new { Name = name.Text.Trim(), MobileNo = Convert.ToInt32(number.Text.Trim()), Gender = gender.SelectedItem.ToString().Trim(), Division = division.SelectedItem.ToString().Trim(), ZipCode = Convert.ToInt32(zip.Text.Trim()), PresentAddress = prAddress.Text.Trim(), PermanentAddress = Peddress.Text.Trim(), Balance = Convert.ToInt32(balance.Text.Trim()), Nid = Convert.ToInt32(nid.Text.Trim()), BirthCertificate = Convert.ToInt32(bcertificate.Text.Trim()), Email = email.Text.Trim(), UserName = username.Text.Trim(), Password = password.Text.Trim() }; var result = CustomerController.AddCustomer(customer); if (result) { confirmReg.Visible = true; // this.Hide(); new LoginPage().Show(); } } catch (FormatException) { reject.Visible = true; } } }