// Evento de botón actualizar un cliente private void button1_Click_1(object sender, EventArgs e) { Client client = new Client { ClientAdress = this.txtAddress.Text, ClientEmail = this.txtMail.Text, ClientName = this.txtName.Text, ClientNif = this.txtNIF.Text, ClientSurname1 = this.txtSurname1.Text, ClientSurname2 = this.txtSurname2.Text, CLientTelephone = this.txtPhone.Text, ClientDateOfBirth = DateTime.Parse(this.dtBirthDate.Text), ClientId = new Guid(this.lbId.Text), }; bool isUpdated = BusinessCustomer.UpdateCustomer(client); if (isUpdated) { RefreshDataGridView(); CleanFields(); MessageBox.Show("Cliente actualizado correctamente"); } else { MessageBox.Show("Ha ocurrido un error actualizando los campos del cliente"); } }
public void Run() { /* * Abstract classes cannot be instanced */ //var customer = new Customer(); var consumerCustomer = new ConsumerCustomer { Address = "King's Landing", Email = "*****@*****.**", Id = Guid.NewGuid(), Name = "Jon Snow", Type = "Basic" }; consumerCustomer.Display(); var businessCustomer = new BusinessCustomer { Address = "Pentos", CUI = "12322322", Id = Guid.NewGuid(), Name = "Iron Bank", VAT = 21.0 }; businessCustomer.Display(); }
// Evento para insertar un nuevo cliente private void btInsert_Click(object sender, EventArgs e) { bool isValid = ValidateField(); if (isValid) { Client client = new Client { ClientAdress = this.txtInsertAddress.Text, ClientEmail = this.txtInsertMail.Text, ClientName = this.txtInsertName.Text, ClientNif = this.txtInsertNif.Text, ClientSurname1 = this.txtInsertSurname1.Text, ClientSurname2 = this.txtInsertSurname2.Text, CLientTelephone = this.txtInsertPhone.Text, ClientDateOfBirth = DateTime.Parse(this.dtInsertBirthDate.Text), ClientId = Guid.NewGuid() }; var hasBeenInserted = BusinessCustomer.InsertCustomer(client); if (hasBeenInserted) { RefreshDataGridView(); MessageBox.Show("Cliente insertado correctamente"); CleanFieldsInserted(); } else { MessageBox.Show("Error al insertar cliente"); } } }
public ActionResult DeleteConfirmed(int id) { BusinessCustomer businessCustomer = _businessCustomerRepository.Get().Include(x => x.SalesAgent).Where(x => x.BusinessCustomerId == id).Fetch().FirstOrDefault(); _businessCustomerRepository.Delete(businessCustomer); return(RedirectToAction("Index")); }
public void Run() { var customer = new Customer { Id = Guid.NewGuid() }; customer.Display(); var consumerCustomer = new ConsumerCustomer { Id = Guid.NewGuid(), Address = "Pentos", Email = "*****@*****.**", Name = "Grey Worm", Type = "Standard" }; consumerCustomer.Display(); var businessCustomer = new BusinessCustomer { Id = Guid.NewGuid(), Address = "Pentos", Name = "Iron Bank", CUI = "3654588", VAT = 10.2 }; businessCustomer.Display(); }
//Método para Refrescar la información de la tabla private void RefreshDataGridView() { List <Client> customer = BusinessCustomer.GetAllCustomer().ToList(); this.dtgridCustomer.DataSource = customer; DisabledFields(); }
public void BusinessAccount_Debit_ExceedLimit() { decimal debitAmount = 250; decimal initalBalance = 100; decimal expected = 100; decimal overdraftLimit = 100; BusinessCustomer bc = new BusinessCustomer() { CustomerID = Guid.NewGuid(), ContactInformation = new Contact() { FirstName = "test", LastName = "test", Address = "123 test street", Email = "*****@*****.**", PhoneNumbers = new List <string>() { "123-122" } }, RegisteredName = "Acme Inc", TradingName = "ACE" }; BusinessAccount ba = new BusinessAccount(bc, initalBalance, overdraftLimit); ba.Debit(debitAmount); decimal actual = ba.Balance; Assert.AreEqual(expected, actual); }
public string CustomerInsert(CustomerInfo customerInfo) { string result = string.Empty; try { var bc = new BusinessCustomer(); bc.Entity.CustNo = customerInfo.CustIdOnCenterServer; bc.Entity.CustName = customerInfo.CustName; bc.Entity.CustShortName = customerInfo.CustShortName; bc.Entity.CustBank = customerInfo.CustBank; bc.Entity.CustBankAccount = customerInfo.CustBankAccount; bc.Entity.CustBankTitle = customerInfo.CustBankTitle; bc.Entity.CustContact = customerInfo.CustContact; bc.Entity.CustTel = customerInfo.CustTel; bc.Entity.BusinessScope = customerInfo.BusinessScope; bc.Entity.CustContactMobile = customerInfo.CustContactMobile; bc.Entity.CustEmail = customerInfo.CustEmail; bc.Entity.RepIDCard = customerInfo.RepIDCard; bc.Entity.Representative = customerInfo.Representative; bc.Entity.CustType = customerInfo.CustType; bc.Entity.CustLicenseNo = customerInfo.CustLicenseNO; bc.Entity.IsExternal = Convert.ToBoolean(customerInfo.IsExternal); bc.Entity.CustCreator = "客户系统同步"; bc.Entity.CustCreateDate = DateTime.Now; result = Save("insert", bc); } catch (Exception ex) { result = ex.ToString(); } return(result); }
public async Task <IActionResult> Login(CustomerViewModel customerView) { var sessionValue = HttpContext.Session.GetInt32("CustomerId"); if (sessionValue == null) { var businessCustomer = new BusinessCustomer { Username = customerView.Username, Password = customerView.Password }; var databaseCustomer = await _repository.loginCustomerAsync(businessCustomer); if (databaseCustomer != null) { HttpContext.Session.SetInt32("CustomerId", databaseCustomer.CustomerId); HttpContext.Session.SetString("Username", databaseCustomer.Username); _logger.LogInformation("Session created for {0}", customerView.Username); return(RedirectToAction("Index", "Home")); } ModelState.AddModelError("Password", "Invalid username or password."); _logger.LogWarning("Invalid username or password."); return(View()); } return(RedirectToAction("Index", "Home")); }
static void Main() { var pesho = new IndividualCustomer("Pesho"); var goshoOOD = new BusinessCustomer("GoshoOOD"); var petrana = new BusinessCustomer("PetranaEOOD"); var depositAcc = new Deposit(pesho, 5000, 6); Console.WriteLine("Pesho`s balance : {0}", depositAcc.Balance); depositAcc.DepositAmount(6000); Console.WriteLine("Pesho`s balance after deposit: {0}", depositAcc.Balance); Console.WriteLine("Pesho`s interest for 6 months: {0} %", depositAcc.CalculateInterest(6)); depositAcc.WithDrawAmount(10900); Console.WriteLine("Pesho`s balance after withdraw : {0}", depositAcc.Balance); var mortgage = new Mortgage(goshoOOD, 15000, 4); Console.WriteLine("Gosho`s mortgage balance: {0}", mortgage.Balance); mortgage.DepositAmount(32500); Console.WriteLine("Gosho`s mortgage balance after deposit: {0} ", mortgage.Balance); Console.WriteLine("Gosho`s mortgage interest : {0} %", mortgage.CalculateInterest(12)); var loanAcc = new Loan(petrana, 73000, 2); Console.WriteLine("Petrana`s balance : {0}", loanAcc.Balance); Console.WriteLine("Petrana`s interest for 16 months : {0} %", loanAcc.CalculateInterest(16)); loanAcc.DepositAmount(50000); Console.WriteLine("Petrana`s balance after deposit : {0}", loanAcc.Balance); }
public async Task TestListCustomers() { var options = new DbContextOptionsBuilder <BusinessContext>() .UseInMemoryDatabase(databaseName: "test_customer_list") .Options; using (var bc = new BusinessContext(options)) { var repository = new Repository(bc); var customersSn = await repository.listCustomersAsync(); var customerA = new BusinessCustomer { Username = "******" }; var customerB = new BusinessCustomer { Username = "******" }; await repository.createCustomerAsync(customerA); await repository.createCustomerAsync(customerB); var customersSa = await repository.listCustomersAsync(); Assert.Equal(2, customersSa.Count()); Assert.Empty(customersSn); } }
public ActionResult ListCountries(string id) { var busCustomer = new BusinessCustomer(); var retorno = busCustomer.ListCountries(id); return(Json(retorno, JsonRequestBehavior.AllowGet)); }
public void TestBusinessCustomerLastNameCapitalized(string lastName, string expected) { BusinessCustomer customer = new BusinessCustomer(); customer.LastName = lastName; Assert.Equal(expected, customer.LastName); }
public IActionResult NewBusiness(BusinessCustomer customer) { //Get bank object from file, add customer to bank object, then save! var bank = Utility.Utility.GetBankData(_env.WebRootPath); bank.BusinessCustomers.Add(customer); Utility.Utility.SaveBankData(_env.WebRootPath, bank); return(RedirectToAction("Index", "Home", new { message = Message.CreateBusinessCustomerSuccess })); }
public void WithOmittedFirstName() { Customer customer = new BusinessCustomer() { LastName = "Last" }; string expected = "Last"; Assert.AreEqual(expected, customer.FullName); }
public void GeneratesFullName() { Customer customer = new BusinessCustomer() { FirstName = "Test", LastName = "Last" }; string expected = "Test Last"; Assert.AreEqual(expected, customer.FullName); }
public void ValidatesNoFirstName() { var address = new Address("123 Main", AddressType.HOME); Customer customer = new BusinessCustomer() { LastName = "B", EmailAddress = "*****@*****.**", MailingAddress = address }; Assert.AreEqual(false, customer.IsValid); }
public void ValidatesProperCustomer() { var address = new Address("123 Main", AddressType.HOME); Customer customer = new BusinessCustomer() { FirstName = "A", LastName = "B", EmailAddress = "*****@*****.**", MailingAddress = address }; Assert.AreEqual(true, customer.IsValid); }
public void AddressList() { Customer customer = new BusinessCustomer() { FirstName = "Test", LastName = "Last" }; Assert.IsNotNull(customer.AddressList); Assert.AreEqual(0, customer.AddressList.Count); }
public ActionResult Index(Customer customer) { var busCustomer = new BusinessCustomer(); var customers = busCustomer.GetAllCustomers(customer); ViewBag.CompanyName = customer.CompanyName; ViewBag.Country = customer.Country; return(View(customers)); }
public void ValidateHandlesEmptyFields() { var address = new Address("123 Main", AddressType.HOME); Customer customer = new BusinessCustomer() { FirstName = "", LastName = "B", EmailAddress = "*****@*****.**", MailingAddress = address }; Assert.AreEqual(false, customer.IsValid); }
public ActionResult Edit(BusinessCustomer businessCustomer) { if (ModelState.IsValid) { _businessCustomerRepository.Update(businessCustomer); return(RedirectToAction("Index")); } ViewBag.SalesAgentId = new SelectList(_salesAgentRepository.Get().Fetch(), "SalesAgentId", "Name", businessCustomer.SalesAgentId); return(View(businessCustomer)); }
/// <summary> /// Verifies that a customer's username and password match an entity in the database /// </summary> /// <param name="customer">The model with the username and password to check</param> /// <returns>The same parameter customer object with validation successful, false otherwise</returns> public async Task <BusinessCustomer> loginCustomerAsync(BusinessCustomer customer) { Customer databaseCustomer = await _context.Customers.FirstOrDefaultAsync(c => c.Username == customer.Username && c.Password == customer.Password); if (databaseCustomer != null) { customer.CustomerId = databaseCustomer.CustomerId; return(customer); } return(null); }
public void Put(int id, [FromBody] Customer model) { var customer = new BusinessCustomer { Id = id }; Pass.Onto(model, customer); customerService.Update(customer); }
// Método para seleccionar cliente private void selectClient(object sender, DataGridViewCellEventArgs e) { var rows = this.dataGridView1.CurrentRow; if (rows == null) { return; } var client = BusinessCustomer.GetClientById(new Guid(rows.Cells["ClientId"].Value.ToString())); this._sells.AddClient(client); this.Hide(); }
public ActionResult Details(string ID) { var busCustomer = new BusinessCustomer(); var customer = busCustomer.GetById(ID); if (customer == null) { return(View("Erro", new Exception("Registro Não Encontrado"))); } return(View(customer)); }
// GET: BusinessCustomers/Details/5 public ActionResult Details(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } BusinessCustomer businessCustomer = _businessCustomerRepository.Get().Where(x => x.BusinessCustomerId == id).Fetch().FirstOrDefault(); if (businessCustomer == null) { return(HttpNotFound()); } return(View(businessCustomer)); }
public ActionResult Edit(string ID) { var busCustomer = new BusinessCustomer(); var customer = busCustomer.GetById(ID); if (customer == null) { var ex = new Exception("Registro Não encontrado!"); return(View("Erro", ex)); } return(View("New", customer)); }
public IActionResult Business(string id) { try { if (!ModelState.IsValid) { return(StatusCode(StatusCodes.Status500InternalServerError, new Response { Status = "Error", Messages = new Message[] { new Message { Lang_id = 1, MessageLang = "Model state isn't valid!" }, new Message { Lang_id = 2, MessageLang = "Состояние модели недействительно!" }, new Message { Lang_id = 3, MessageLang = "Model vəziyyəti etibarsızdır!" } } })); } AppUser appUser = _userDbContext.Users.Where(u => u.Id == id) .Include(u => u.City).ThenInclude(c => c.CityNameTranslates) .Include(u => u.Balance) .Include(u => u.Office).ThenInclude(o => o.OfficeNameTranlates).FirstOrDefault(); if (appUser == null) { return(StatusCode(StatusCodes.Status404NotFound)); } BusinessCustomer customer = _businessContext.GetWithCamexId(appUser.CamexId); if (customer == null) { return(StatusCode(StatusCodes.Status404NotFound)); } return(Ok( new BusinessUserAdmin { User = appUser, BusinessCustomer = customer })); } catch (Exception e) { return(StatusCode(StatusCodes.Status500InternalServerError, e.Message)); } }
/// <summary> /// Adds a customer to the database. /// </summary> /// <param name="bCustomer">The customer to add to the database</param> public static void AddCustomer(BusinessCustomer bCustomer) { Log.Information($"Called the Data Access method to add the customer {bCustomer}"); using var context = new TThreeTeasContext(SQLOptions.options); Customer additionalCustomer = new Customer() { FirstName = bCustomer.FirstName, LastName = bCustomer.LastName }; context.Customer.Add(additionalCustomer); context.SaveChanges(); }