private bool AddToList(FindCustomerView model, Customer customer) { bool addToResult = true; if (model.FirstName == null && model.SecondName == null && model.Phone == null && model.Email == null) { addToResult = false; } if (model.FirstName != null && customer.Name != model.FirstName) { addToResult = false; } if (model.SecondName != null && customer.Surname != model.SecondName) { addToResult = false; } if (model.Phone != null && customer.PhoneNumber != model.Phone) { addToResult = false; } if (model.Email != null && customer.Email != model.Email) { addToResult = false; } return(addToResult); }
public void FindCustomerViewProvidesWindowSmartPartInfo() { ISmartPartInfoProvider provider = new FindCustomerView() as ISmartPartInfoProvider; WindowSmartPartInfo spi = provider.GetSmartPartInfo(typeof(WindowSmartPartInfo)) as WindowSmartPartInfo; Assert.IsNotNull(spi); Assert.AreEqual("Find Customer", spi.Title); }
public IActionResult Find(FindCustomerView model) { List <Customer> customers = new List <Customer>(); if (ModelState.IsValid) { var allCustomers = unitOfWork.Customers.GetAll().ToList(); foreach (var customer in allCustomers) { bool addToResult = true; if (model.FirstName == null && model.SecondName == null && model.Phone == null && model.Email == null) { addToResult = false; } if (model.FirstName != null && customer.FirstName != model.FirstName) { addToResult = false; } if (model.SecondName != null && customer.SecondName != model.SecondName) { addToResult = false; } if (model.Phone != null && customer.Phone != model.Phone) { addToResult = false; } if (model.Email != null && customer.Email != model.Email) { addToResult = false; } if (addToResult) { customers.Add(customer); } } HttpContext.Session.Set("list", customers); return(RedirectToAction("FindResult", "Customer")); } return(View(model)); }
public IActionResult Find(FindCustomerView model) { List <Customer> customers = new List <Customer>(); if (ModelState.IsValid) { var allCustomers = unitOfWork.Customers.GetAll().ToList(); foreach (var customer in allCustomers) { if (this.AddToList(model, customer)) { customers.Add(customer); } } HttpContext.Session.Set("list", customers); return(RedirectToAction("FindResult", "Customer")); } return(View(model)); }