public IHttpActionResult Add(AddCustomer customer) { if (!ModelState.IsValid) { return(BadRequest()); } var customerToAdd = new DAL.Models.Customer { Name = customer.Name, Company = customer.Company, Email = customer.Email, Phone = customer.Phone }; var customerAdded = _db.Customers.Add(customerToAdd); _db.SaveChanges(); var customerToReturn = new Customer { Id = customerAdded.Id, Name = customerAdded.Name, Phone = customerAdded.Phone, Email = customerAdded.Email, Company = customerAdded.Company }; return(Ok(new { Data = customerToReturn })); }
private void Button_Click_20(object sender, RoutedEventArgs e) { AddCustomer add = new AddCustomer(); add.Show(); this.Close(); }
public CustomerViewModel() { addCustomer = new AddCustomer(this); deleteCustomer = new DeleteCustomer(this); updateCustomer = new UpdateCustomer(this); SelectCustomer = new CustomerEntity(); CurrentCustomer = new CustomerEntity(); }
private void btnAddCustomer_Click(object sender, EventArgs e) { frmPanel.Controls.Clear(); AddCustomer addCust = new AddCustomer(); addCust.TopLevel = false; frmPanel.Controls.Add(addCust); addCust.Show(); }
public IActionResult Post([FromBody] AddCustomer addCustomer) { var customer = new Customer(addCustomer.FullName, addCustomer.Document, addCustomer.BirthDate); _dbContext.Customer.Add(customer); _dbContext.SaveChanges(); //persistir a operação return(NoContent()); }
public Task Handle(object Command) { return(Command switch { AddCustomer cmd => HandleCreate(cmd), UpdateCustomer cmd => HandleUpdate(cmd.Id, c => c.BusinessCustomerUpdate(cmd.CompanyId, cmd.FirstName, cmd.LastName, cmd.CVR, cmd.EAN, cmd.WWW, cmd.VatCode, cmd.DebitorNo, cmd.Username, cmd.Password, cmd.Text, cmd.AccountNo, cmd.LastUpdate)), DeleteCustomer cmd => HandleDelete(cmd.Id), _ => Task.CompletedTask });
public Task Handle(object Command) { return(Command switch { AddCustomer cmd => HandleCreate(cmd), UpdateCustomer cmd => HandleUpdate(cmd.Id, c => c.PrivateCustomerUpdate(cmd.CompanyId, cmd.FirstName, cmd.LastName, cmd.Username, cmd.Password, cmd.Text, cmd.AccountNo, cmd.LastUpdate)), DeleteCustomer cmd => HandleDelete(cmd.Id), _ => Task.CompletedTask });
private void btnAddCustomer_Click(object sender, EventArgs e) { AddCustomer cusForm = new AddCustomer(); DialogResult dr = cusForm.ShowDialog(); if (dr == DialogResult.OK) { lbxCustomer.Items.Add(cusForm.customer); } }
public void Invalid_When_NamePhoneEmailMissing() { var validator = new AddCustomerValidator(new AddCustomerValidator.CustomerAddressValidator(), new AddCustomerValidator.CustomerPhoneNumberValidator()); var data = new AddCustomer(); var result = validator.TestValidate(data); result.ShouldHaveAnyValidationError(); Assert.Contains(result.Errors, e => e.ErrorMessage == "Name, Email, or Phone Number must be given."); }
private void SaveCustomerGroup() { if (!string.IsNullOrWhiteSpace(txtCustomerCodeFrom.Text) || !string.IsNullOrWhiteSpace(txtCustomerCodeTo.Text)) { if (!CheckRangeData()) { return; } var addTask = AddCustomerGroupAsync(); ProgressDialog.Start(ParentForm, addTask, false, SessionKey); } var loadTask = GetChildCustomersByParentId(ParentCustomerId) .ContinueWith(t => PrepareCustomerGroup(t.Result)); ProgressDialog.Start(ParentForm, loadTask, false, SessionKey); var success = false; var saveTask = ServiceProxyFactory.LifeTime(async factory => { var service = factory.Create <CustomerGroupMasterClient>(); var saveResult = await service.SaveAsync(SessionKey, AddCustomer.ToArray(), DeleteCustomer.ToArray()); success = saveResult?.ProcessResult.Result ?? false; if (!success) { return; } AddCustomer.Clear(); DeleteCustomer.Clear(); var customerGroup = await GetChildCustomersByParentId(ParentCustomerId); customerGroup = customerGroup.OrderBy((x => x.ChildCustomerCode)).ToList(); CustomerModifyList = customerGroup; CustomerOriginList = customerGroup; }); ProgressDialog.Start(ParentForm, saveTask, false, SessionKey); if (!success) { ShowWarningDialog(MsgErrSaveError); return; } grdCustomerModify.DataSource = new BindingSource(CustomerModifyList, null); grdCustomerOrigin.DataSource = new BindingSource(CustomerOriginList, null); txtCustomerCodeFrom.Focus(); ClearChildCustomerInfo(); Modified = false; DispStatusMessage(MsgInfSaveSuccess); }
private void buttonAdd_Click(object sender, RoutedEventArgs e) { var asa = _accountService.getCustomer(5); if (_isCustomersSelected) { var addCustomerWindow = new AddCustomer(); addCustomerWindow.superView = this; addCustomerWindow.ShowDialog(); } }
private void button1_Click(object sender, EventArgs e) { Customer changeCustomer = lbxCustomer.SelectedItem as Customer; AddCustomer cust = new AddCustomer(changeCustomer); DialogResult dr = cust.ShowDialog(); if (dr == DialogResult.OK) { lbxCustomer.Items.Remove(lbxCustomer.SelectedItem); lbxCustomer.Items.Add(changeCustomer); } }
/// <summary> /// Choose this to enter the Add Information menu /// </summary> public static void AddInformation() { var customer = new AddCustomer(); var bicycle = new AddBicycle(); var bookingDetail = new AddBooking_detail(); var bicycleBrand = new AddBicycle_brand(); Console.Clear(); Console.WriteLine("1: Add Customer"); Console.WriteLine("2: Add Bicycle"); Console.WriteLine("3: Add Booking_detail"); Console.WriteLine("4: Add Bicycle_brand"); Console.WriteLine("5: Return to Main Menu"); Console.WriteLine(""); var userChoice = Console.ReadLine(); switch (userChoice) { case "1": customer.AddNewCustomer(); ReturnToMainMenu(); break; case "2": bicycle.AddNewBicycle(); ReturnToMainMenu(); break; case "3": bookingDetail.AddNewBooking_detail(); ReturnToMainMenu(); break; case "4": bicycleBrand.AddNewBicycleBrand(); ReturnToMainMenu(); break; case "5": MainMenu(); break; default: Console.Clear(); Console.WriteLine("Input does not exist!.. Press any key except the one you pressed to get here!.. try again!.. "); Console.ReadKey(); AddInformation(); break; } }
public Customer AddCustomer() { _mView = new AddCustomer(); AddCustomerViewModel cViewModel = new AddCustomerViewModel(); cViewModel.Model = new Customer(); cViewModel.OkCommand = new RelayCommand(ExecuteOkCommand); cViewModel.CancelCommand = new RelayCommand(ExecuteCancelCommand); _mView.DataContext = cViewModel; return(_mView.ShowDialog() == true ? cViewModel.Model : null); }
private void customerAddToolStripMenuItem_Click(object sender, EventArgs e) { if (_instanceAddCustomer == null) { CloseAllForms(); _instanceAddCustomer = new AddCustomer(); _instanceAddCustomer.MdiParent = this; _instanceAddCustomer.FormClosed += instanceAddCustomerHadBeenClosed; } else { ShowMessage(); } _instanceAddCustomer.Show(); }
static void Main(string[] args) { DatabaseInterface db = new DatabaseInterface("BANGAZONCLI_DB"); db.CheckDatabaseTable("Customer", DbTables.Customer); db.CheckDatabaseTable("Product", DbTables.Product); db.CheckDatabaseTable("PaymentType", DbTables.PaymentType); db.CheckDatabaseTable("[Order]", DbTables.Order); db.CheckDatabaseTable("OrderProduct", DbTables.OrderProduct); DbInitializer.Initialize(db); MainMenu menu = new MainMenu(); CustomerManager customerManager = new CustomerManager(db); OrderManager orderManager = new OrderManager(db); // Choice will hold the number entered by the user // after main menu ws displayed int choice; do { // Show the main menu choice = menu.Show(); switch (choice) { case 1: AddCustomer.DoAction(customerManager); break; case 2: ChooseActiveCustomer.DoAction(customerManager); break; case 3: AddPaymentType.DoAction(customerManager); break; case 5: AddProductToCart.DoAction(orderManager); break; case 6: CloseOrder.DoAction(orderManager); break; } } while (choice != 7); }
private void pictureBox1_Click(object sender, EventArgs e) { try { Home.Home_pnl.Visible = false; AddCustomer _AddCustomer = new AddCustomer(); _AddCustomer.MdiParent = this; _AddCustomer.WindowState = FormWindowState.Maximized; _AddCustomer.Show(); _AddCustomer.Focus(); } catch (Exception ex) { notifyIcon1.ShowBalloonTip(1000, this.Name, ex.Message, ToolTipIcon.Info);; } }
public void CommandExecuteCanHandleException() { //Arrange var internalClient = A.Fake<ICommandServiceClient>(); A.CallTo(() => internalClient.Execute(A<AddCustomer>.Ignored)).Throws ( new Exception("Exception Message") ); var client = new myCustomers.QuartetClientFactory.QuartetCommandServiceWrapper(internalClient); var command = new AddCustomer(); //Act client.Execute(command); }
public void CommandExecuteCanHandleFaultExceptionEmptyValidationMessage() { //Arrange var internalClient = A.Fake<ICommandServiceClient>(); A.CallTo(() => internalClient.Execute(A<AddCustomer>.Ignored)).Throws ( new FaultException<ValidationResult>(new ValidationResult { Errors = { } }, "Empty ValidationResult fault exception message") ); var client = new myCustomers.QuartetClientFactory.QuartetCommandServiceWrapper(internalClient); var command = new AddCustomer(); //Act client.Execute(command); }
public async Task Customer_IsSavedToDbContext() { var entity = new DataModel.Customer { Name = "test customer" }; IRequestHandler <AddCustomer, Unit> systemUnderTest = CreateSystemUnderTest(entity, out var context); var request = new AddCustomer { Name = "test customer" }; await systemUnderTest.Handle(request, CancellationToken.None); Assert.Contains(context.Customers, c => c.Name == "test customer"); }
private void addCustomerToolStripMenuItem_Click(object sender, EventArgs e) { try { if (_AddCustomer.IsDisposed) { _AddCustomer = new AddCustomer(); } Home.Home_pnl.Visible = false; _AddCustomer.MdiParent = this; _AddCustomer.WindowState = FormWindowState.Maximized; _AddCustomer.Show(); _AddCustomer.Focus(); } catch (Exception ex) { notifyIcon1.ShowBalloonTip(1000, this.Name, ex.Message, ToolTipIcon.Info);; } }
public async Task <ActionResult> Add_Customers(AddCustomer customerDTO) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var customer = new Customer() { name = customerDTO.name }; await _context.Customer.AddAsync(customer); await _context.SaveChangesAsync(); await _context.SaveChangesAsync(); return(CreatedAtAction("GetStudents", new { id = customer.Id }, customerDTO)); }
public ActionResult Create(Customer c) { try { var request = new AddCustomer() { Name = c.Name, Surname = c.Surname, EmailAddress = c.EmailAddress, TelephoneNumber = c.TelephoneNumber }; mediator.Send(request); return(RedirectToAction(nameof(Index))); } catch { return(View()); } }
public void AddCustomer() { customer cust = new customer(); AddCustomer addWindow = new AddCustomer(); // Sets the window's context and gives it the types available, that aren't deleted addWindow.DataContext = new { customer = cust }; addWindow.ShowDialog(); try { dataHandler.AddOrUpdate(cust); } catch (Exception e) { System.Windows.MessageBox.Show("Error: " + e.Message); } NotifyOfPropertyChange("Customers"); }
public IActionResult AddCustomer(AddCustomer newcustomer) { if (_context.customers.Where(c => c.CustomerName == newcustomer.CustomerName).SingleOrDefault() != null) { ModelState.AddModelError("CustomerName", "Cannot have repeat customers!"); // checking if customer name already exists in the db } if (ModelState.IsValid) { Customer customer = new Customer { CustomerName = newcustomer.CustomerName, CreatedAt = DateTime.Now, UpdatedAt = DateTime.Now, }; _context.customers.Add(customer); _context.SaveChanges(); RedirectToAction("Index"); } ViewBag.customer = _context.customers.ToList(); ViewBag.customersearch = null; return(View("Index")); }
void ReleaseDesignerOutlets() { if (AddCustomer != null) { AddCustomer.Dispose(); AddCustomer = null; } if (Camera != null) { Camera.Dispose(); Camera = null; } if (EmployeesTableView != null) { EmployeesTableView.Dispose(); EmployeesTableView = null; } if (mFullUpdateDateText != null) { mFullUpdateDateText.Dispose(); mFullUpdateDateText = null; } if (NavigationItem != null) { NavigationItem.Dispose(); NavigationItem = null; } if (RefreshBtn != null) { RefreshBtn.Dispose(); RefreshBtn = null; } }
/// <summary> /// 債権代表者マスター 登録前に AddCusotmer, DeleteCustomer を設定する処理 /// </summary> /// <param name="customerGroupDB"></param> private void PrepareCustomerGroup(List <CustomerGroup> customerGroupDB) { if (CustomerModifyList.Any()) { AddCustomer.Clear(); DeleteCustomer.Clear(); foreach (var item in CustomerModifyList .Where(x => !customerGroupDB.Any(y => y.ChildCustomerCode == x.ChildCustomerCode))) { item.ParentCustomerId = ParentCustomerId; item.CreateBy = Login.UserId; item.UpdateBy = Login.UserId; AddCustomer.Add(item); } } foreach (var item in customerGroupDB .Where(x => !CustomerModifyList.Any(y => y.ChildCustomerCode == x.ChildCustomerCode))) { DeleteCustomer.Add(item); } }
public void Modify(customer cust) { AddCustomer addWindow = new AddCustomer(); // Sets the window's context and gives it the types available, that aren't deleted addWindow.DataContext = new { customer = cust }; if (addWindow.ShowDialog() == true) { try { dataHandler.AddOrUpdate(cust); } catch (Exception e) { System.Windows.MessageBox.Show("Error: " + e.Message); } } else { ((System.Data.Entity.Infrastructure.IObjectContextAdapter)dataHandler.GetEntities()).ObjectContext.Refresh(System.Data.Entity.Core.Objects.RefreshMode.StoreWins, cust); } NotifyOfPropertyChange("Customers"); }
void GoRootForm() { if (RootForm == "Sell") { Sell sell = (Sell)Application.OpenForms["Sell"]; //=> Props sell.CustomerToken = CustomerToken; //update sell.Update(); } //Close ParentForm of ParentForm Forms.PointOfSale.Customers customers = (Forms.PointOfSale.Customers)Application.OpenForms["Customers"]; customers.Hide(); //Close ParentForm AddCustomer addCustomer = (AddCustomer)Application.OpenForms["AddCustomer"]; addCustomer.Hide(); this.Hide(); }
public ActionResult AddCustomer(AddCustomer regCustomer) { string salt = AdminService.generateSalt(); var passwordAndSalt = regCustomer.Password + salt; byte[] passwordDB = AdminService.createHash(passwordAndSalt); PostalArea postalArea = new PostalArea() { Area = regCustomer.PostalArea, PostCode = regCustomer.PostCode }; _adminService.addPostalArea(postalArea); Customer customer = new Customer() { BirthNo = regCustomer.BirthNo, FirstName = regCustomer.FirstName, LastName = regCustomer.LastName, Address = regCustomer.Address, PhoneNo = regCustomer.PhoneNo, PostCode = regCustomer.PostCode, Password = passwordDB, Salt = salt }; if (_adminService.addCustomer(customer)) { // If succesfull: return(Json(new { success = true })); } else { // If not successfull: return(PartialView("_AddCustomerPartial", regCustomer)); } }
public HomeController() { repository = new AddCustomer(); }
public void User_Can_Add_Customer() { AddCustomer.GoToAddCustomer(); Assert.IsTrue(AddCustomer.customerIsAdded, "Cannot add customer"); }
public void CommandExecuteCanHandleFaultExceptionOneValidationMessage() { //Arrange var internalClient = A.Fake<ICommandServiceClient>(); A.CallTo(() => internalClient.Execute(A<AddCustomer>.Ignored)).Throws ( new FaultException<ValidationResult>(new ValidationResult { Errors = new string[] { "AddCustomer Failed validation due to reasons specified right here" } }, "One ValidationResult fault exception message") ); var client = new myCustomers.QuartetClientFactory.QuartetCommandServiceWrapper(internalClient); var command = new AddCustomer(); //Act client.Execute(command); }