public CustomerVm GetCustomer(Expression <Func <Customer, bool> > filterPredicate = null) { Customer customer = _uow.Repository <Customer>().Get(filterPredicate, false, null); CustomerVm customerVm = Mapper.Map <CustomerVm>(customer); return(customerVm); }
public async Task <IActionResult> Edit(int id, [Bind("CustomerId,FirstMidName,LastName,CompanyName,ContactPerson,ContactTitle,Address,City,Region,PostCode,Country,Phone,Phone2,Fax,Email,CompanyId")] CustomerVm cust) { if (id != cust.CustomerId) { return(NotFound()); } if (ModelState.IsValid) { try { await _CustomerMapper.BlUpdateAsync(cust); } catch (DbUpdateConcurrencyException) { var Exists = _CustomerMapper.CustomerExists((cust.CustomerId)); if (!Exists) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } //var company = _companymapper.BlGetAllCompany(); //ViewData["CompanyID"] = new SelectList(company, "CompanyID", "CompanyName", cust.CustomerID); return(View(cust)); }
public Guid?Post(CustomerVm customerVm) { try { var customer = new Customer() { Will = _willService.Get(customerVm.WillId), FirstName = customerVm.FirstName, LastName = customerVm.LastName, DateOfBirth = new DateTime(customerVm.DateOfBirth.Year, customerVm.DateOfBirth.Month, customerVm.DateOfBirth.Day), Address = customerVm.Address.ToAddress(), Telephone = customerVm.Telephone, MaritalStatusId = customerVm.MaritalStatusId, //MaritalStatus = _maritalStatusVmService.Get(customerVm.MaritalStatusId), UpdatedUtc = DateTime.UtcNow }; return(_customerService.AddOrUpdate(customer)); } catch (Exception e) { _logger.LogWarning("CustomerVmService Post exception", e.Message); return(null); } }
public void AddOrUpdateCustomer(CustomerVm customerVm) { var customer = Mapper.Map <Customer>(customerVm); _uow.Repository <Customer>().AddOrUpdate(x => x.CustomerID == customer.CustomerID, customer); _uow.Save(); }
public ActionResult SavePaymentMethod(string paymentMethod) { try { if (string.IsNullOrWhiteSpace(paymentMethod)) { Response.StatusCode = (int)HttpStatusCode.BadRequest; var validationErrors = new List <KeyValuePair <string, string> >(); validationErrors.Add(new KeyValuePair <string, string>("PaymentMethod", "Payment Method is mandatory")); return(Json(new { validationErrors })); } var customer = Customer; customer.PaymentMethod = paymentMethod; Customer = customer; return(new JsonResult()); } catch (Exception ex) { var exceptionMessage = "Error saving payment method"; Logger.Error(exceptionMessage, ex); Response.StatusCode = (int)HttpStatusCode.InternalServerError; return(Json(new { exceptionMessage })); } }
public static bool Display(CustomerVm model) { // damit wir beim Abbrechen nicht aus Versehen etwas // übernehmen, das wir nicht wollen, arbeiten wir // temporär mit einer Kopie var vm = PoorMansObjectCloner.Clone <CustomerVm>(model); var win = new CustomerWindow(vm); // wir zeigen das Fenster als Dialogfenster (blockierend!) an if (win.ShowDialog() != true) { // Abbrechen ... Debug.WriteLine("Bearbeitung des Kunden abgebrochen"); return(false); } // Ok geklickt... Debug.WriteLine("Bearbeitung des Kunden beendet"); // nun wollen wir die geänderten Properties zurück ins // Originalobjekt übernehmen PoorMansObjectCloner.CopyProperties(vm, model); return(true); }
public ActionResult Edit(CustomerVm customerVm) { try { var customer = Db.Customers.Find(Guid.Parse(customerVm.Id)); if (customer != null) { customer.WhiteLabel = customerVm.WhiteLabel; customer.CompanyName = customerVm.CompanyName; customer.CompanyLogo = customerVm.CompanyLogo; customer.ReportTemplate = customerVm.ReportTemplate; customer.WebDomain = customerVm.WebDomain; customer.Email = customerVm.Email; customer.Phone = customerVm.Phone; customer.IsUseOpenModel = customerVm.IsUseOpenModel; customer.OpenInitial = customerVm.OpenInitial; customer.OpenEnd = customerVm.OpenEnd; customer.ClickInitial = customerVm.ClickInitial; customer.ClickEnd = customerVm.ClickEnd; } Db.SaveChanges(); TempData["Success"] = "White Label settings has been updated successfully!"; SetForceCustomers(true); return(RedirectToAction("Index")); } catch (Exception ex) { // ignored } return(View("Error")); }
public CustomerWindow(CustomerVm model) { InitializeComponent(); // falls kein Model übergeben wurde, erstellen wir einfach eines: Model = model ?? new CustomerVm(); DataContext = Model; }
public IActionResult Get(int id) { var customer = new CustomerVm().Get(id); if (customer == null) { return(NotFound("Customer not found")); } return(Ok(customer)); }
public IActionResult NewOrEditCustomer(CustomerVm model) { if (ModelState.IsValid) { var entityModel = CustomerVm.MapToEntityModel(model); _settingsBlProvider.AddOrUpdateCustomer(entityModel, model.UserIds); } return(RedirectToAction("CustomerManagement", "Settings")); }
public IActionResult DeleteCustomer(CustomerVm model) { var entityModel = CustomerVm.MapToEntityModel(model); _settingsBlProvider.DeleteCustomer(entityModel); return(RedirectToAction("CustomerManagement", "Settings")); }
public async Task <IActionResult> Create([Bind("CustomerId,FirstMidName,LastName,CompanyName,ContactPerson,ContactTitle,Address,City,Region,PostCode,Country,Phone,Phone2,Fax,Email,CompanyId")] CustomerVm post) { if (ModelState.IsValid) { await _CustomerMapper.BlInser(post); return(RedirectToAction(nameof(Index))); } var company = _companymapper.BlGetAllCompany(); ViewData["CompanyId"] = new SelectList(company, "CompanyId", "CompanyName", post.CompanyId); return(View(post)); }
public CustomersPg() { this.InitializeComponent(); //Data-Initialization-B Step 2: Create a ViewModel object based on the ViewModel class. CustomerVm viewModel = new CustomerVm(); // Load the records into recordList viewModel.GetDataAsync(); //Data-Initialization-C Step 10: Instruct the MainPage.xml to use this viewModel to retrieve and store its data this.DataContext = viewModel; }
public ActionResult EditCustomer(string id) { var customer = _dataContext.Find(id); if (customer == null) { return(HttpNotFound()); } var customerVm = new CustomerVm(customer); return(View(customerVm)); }
public async Task ShowModal(CustomerVm customerVm) { await CoseTerminal(); stage = CheckoutStages.Idle; AvalibleTerminals = new List <string>(); TerminalId = null; SelectedCustomerId = customerVm.Id; SelectedCustomerName = customerVm.Name; modalRef.Show(); StartScanner(); }
public void AddCustomer(CustomerVm customer) { var _customer = new Customer { FirstName = customer.FirstName, LastName = customer.LastName, Email = customer.Email, Address = customer.Address, PostalCode = customer.PostalCode, TelephoneNumber = customer.TelephoneNumber }; _context.Customers.Add(_customer); _context.SaveChanges(); }
public IActionResult NewOrEditCustomer(long customerId) { var customerVm = CustomerVm.MapToViewModel(_settingsBlProvider.GetCustomerById(customerId) ?? new Customer()); ViewBag.AllUsers = UserBlProvider.GetUsers().Select(t => new SelectModel() { label = t.Email, value = t.Id.ToString() }).ToList(); if (customerVm?.Address == null) { customerVm.Address = new AddressVm(); } return(PartialView("_NewOrEditCustomer", customerVm)); }
public void UpdateCustomer(CustomerVm vm) { // aus DB laden var dto = CustomerClient.GetKunde(new GetKundeRequest() { KundeId = vm.Id }); // properties kopieren dto.Nachname = vm.Nachname; dto.Vorname = vm.Vorname; dto.Geburtsdatum = vm.Geburtstag.ToTimestamp(); // in DB schreiben CustomerClient.UpdateKunde(dto, Metadata.Empty); }
public ActionResult AddCustomer(CustomerVm sender) { if (!ModelState.IsValid) { return(View(sender)); } var value = new Customer() { Id = sender.Id, Name = sender.Name, PhoneNumber = sender.PhoneNumber }; _dataContext.Insert(value); _dataContext.Commit(); return(RedirectToAction("Index")); }
private CustomerVm Populate(Customer customer, AddressVm addressVm) { var customerVm = new CustomerVm { WillId = customer.Will.Id, FirstName = customer.FirstName, LastName = customer.LastName, Address = PopulateAddressVm(customer, addressVm), DateOfBirth = new DateVm { DateOfBirth = customer.DateOfBirth.Date, Day = customer.DateOfBirth.Day, Month = customer.DateOfBirth.Month, Year = customer.DateOfBirth.Year, } }; return(customerVm); }
// GET: Admin public ActionResult Index() { using (AutoInsurancedBEntities db = new AutoInsurancedBEntities()) { var customers = db.Customers; var customerVms = new List <CustomerVm>(); foreach (var customer in customers) { var customerVm = new CustomerVm { FirstName = customer.FirstName, LastName = customer.LastName, EmailAddress = customer.EmailAddress, Rate = customer.Rate ?? -1 }; customerVms.Add(customerVm); } return(View(customerVms)); } }
public Customer UpdateCustomerById(int customerId, CustomerVm customer) { var _customer = _context.Customers.FirstOrDefault(n => n.Id == customerId); if (_customer is null) { return(_customer); } _customer.FirstName = customer.FirstName; _customer.LastName = customer.LastName; _customer.Email = customer.Email; _customer.Address = customer.Address; _customer.PostalCode = customer.PostalCode; _customer.TelephoneNumber = customer.TelephoneNumber; _context.SaveChanges(); return(_customer); }
public void CustomerNameCorrectlyReflectsFirstNameAndLastName() { // Triple-A-Vorgehen: // 1. (A)rrange // 2. (A)ct // 3. (A)ssert // 1. (A)rrange var vm = new CustomerVm() { Vorname = "Max", Nachname = "Muster" }; // 2. (A)ct vm.Vorname = "Bea"; // 3. (A)ssert Assert.AreEqual("Bea Muster", vm.Name); }
public async Task <CustomerVm> Get(Guid id) { var customerVm = new CustomerVm() { Address = await _addressVmService.Get() }; if (id.IsGuid()) { var customer = _customerService.Get(id); if (customer == null) { throw new ArgumentNullException(nameof(id)); } customerVm = Populate(customer, customerVm.Address); } return(customerVm); }
public ActionResult EditCustomer(CustomerVm sender) { if (!ModelState.IsValid) { return(View(sender)); } var customer = _dataContext.Find(sender.Id); if (customer == null) { return(HttpNotFound()); } customer.Name = sender.Name; customer.PhoneNumber = sender.PhoneNumber; _dataContext.Update(customer); _dataContext.Commit(); return(RedirectToAction("Index")); }
public IActionResult Bookings(Guid?id) { if (id == null) { return(NotFound()); } var customer = _customersRepository.GetCustomerById(id); CustomerVm vm = new CustomerVm(); vm.Customer = customer; var customerBookings = _customersRepository.GetRentalsByCustomerId(id); if (vm == null) { return(NotFound()); } return(View(vm)); }
public ActionResult SaveDeliveryAddress(CustomerVm customer) { try { if (ModelState.IsValid) { Customer = customer; return(new JsonResult()); } Response.StatusCode = (int)HttpStatusCode.BadRequest; return(Json(new { validationErrors = GetErrorMessages() })); } catch (Exception ex) { var exceptionMessage = "Error saving delivery address"; Logger.Error(exceptionMessage, ex); Response.StatusCode = (int)HttpStatusCode.InternalServerError; return(Json(new { exceptionMessage })); } }
public ActionResult New(CustomerVm customerVm) { try { var customer = new Customer { Id = Guid.NewGuid(), CreatedAt = DateTime.Now, CreatedBy = LoggedInUser.Id, WhiteLabel = customerVm.WhiteLabel, CompanyName = customerVm.CompanyName, CompanyLogo = customerVm.CompanyLogo, ReportTemplate = customerVm.ReportTemplate, WebDomain = customerVm.WebDomain, Email = customerVm.Email, Phone = customerVm.Phone, IsUseOpenModel = customerVm.IsUseOpenModel, OpenInitial = customerVm.OpenInitial, OpenEnd = customerVm.OpenEnd, ClickInitial = customerVm.ClickInitial, ClickEnd = customerVm.ClickEnd }; Db.Customers.Add(customer); Db.SaveChanges(); SetForceCustomers(true); TempData["Success"] = "New White Label has been added successfully!"; return(RedirectToAction("Index")); } catch (Exception ex) { // } return(View("Error")); }
public ActionResult Edit(Guid?id) { if (id == null) { throw new HttpException(400, "Bad Request"); } var x = Db.Customers.Find(id); if (x == null) { throw new HttpException(404, "Not found"); } var customerVm = new CustomerVm { Id = x.Id.ToString(), WhiteLabel = x.WhiteLabel, CompanyName = x.CompanyName, CompanyLogo = x.CompanyLogo, ReportTemplate = x.ReportTemplate, WebDomain = x.WebDomain, Email = x.Email, Phone = x.Phone, IsUseOpenModel = x.IsUseOpenModel, OpenInitial = x.OpenInitial, OpenEnd = x.OpenEnd, ClickInitial = x.ClickInitial, ClickEnd = x.ClickEnd, DateCreated = x.CreatedAt.ToString() }; ViewBag.ReportTemplate = new SelectList(ReportTemplates, "Value", "Text", customerVm.ReportTemplate); string view = IsNxs ? "NewNXS" : "New"; return(View(view, customerVm)); }
public async Task BlUpdateAsync(CustomerVm Customer) { var editMap = Mapper.Map <CustomerVm, Customer>(Customer); await _customerRepository.UpdateAsync(editMap); }