// GET: 客戶銀行資訊/Create public ActionResult Create() { var 客戶資料 = customerRepo.All(); ViewBag.客戶Id = new SelectList(客戶資料, "Id", "客戶名稱"); return(View()); }
public void Delete_Should_Delete_The_Customer_And_Should_Return_All_Count_As_One() { var customer1 = new Domain.Customer("Caner Tosuner", "IST", DateTime.Today.AddYears(28)); var customer2 = new Domain.Customer("Caner Tosuner", "IST", DateTime.Today.AddYears(28)); var options = new DbContextOptionsBuilder <CustomerDbContext>() .UseInMemoryDatabase("customer_db") .Options; using (var context = new CustomerDbContext(options)) { var repository = new CustomerRepository(context); repository.Save(customer1); repository.Save(customer2); context.SaveChanges(); } using (var context = new CustomerDbContext(options)) { var repository = new CustomerRepository(context); repository.Delete(customer1.Id); context.SaveChanges(); } using (var context = new CustomerDbContext(options)) { var repository = new CustomerRepository(context); repository.All().Count().Should().Be(1); } }
public static List <Customer> GetCustomersByOrderSizeDescending() { var coRep = new CustomerRepository(); var Cs = coRep.All().ToList(); return(Cs.OrderByDescending(c => c.TotalSales).ToList()); }
public void DeleteCustomer_AddTwoCustomerAndDeleteOne_ReturnCustomersCountAsOne() { var customer1 = new Domain.Customer("ali", "ist", DateTime.Today.AddYears(-30)); var customer2 = new Domain.Customer("veli", "ank", DateTime.Today.AddYears(-25)); var options = CreateNewContextOptions(); using (var context = new CustomerDbContext(options)) { var repository = new CustomerRepository(context); repository.Save(customer1); repository.Save(customer2); context.SaveChanges(); } using (var context = new CustomerDbContext(options)) { var repository = new CustomerRepository(context); var customerToBeDelete = repository.All().First(); repository.Delete(customerToBeDelete.Id); context.SaveChanges(); } using (var context = new CustomerDbContext(options)) { var repository = new CustomerRepository(context); var customerCount = repository.All().Count(); customerCount.Should().Be(1); } }
public static List <Customer> GetCustomersWithOrders() { var coRep = new CustomerRepository(); var Cs = coRep.All(); return(Cs.Where(c => c.SalesOrders.Count > 0).ToList()); //return coRep.Filter(c => c.CustomerId.Equals((from so in salesOdersa select so.CustomerId))).ToList(); }
public static Customer GetLargestCustomer() { var soRep = new SalesOrderRepository(); //return soRep.All().OrderByDescending(so => so.TotalSales).FirstOrDefault().CustomerId; var coRep = new CustomerRepository(); var Cs = coRep.All().ToList(); var selected = Cs.OrderByDescending(c => c.TotalSales); return(selected.FirstOrDefault()); }
public List <Customer> GetCustomers() { var customers = CustomerRepository.All().ToList(); foreach (var customer in customers) { customer.IsUsed = ProjectRepository.Where(p => p.CustomerId == customer.CustomerId).FirstOrDefault() != null; customer.UsedCaption = customer.IsUsed ? Desktop.Yes : Desktop.No; } return(customers); }
// GET: Customer public ActionResult Index() { using (ICustomerRepository _customerRepo = new CustomerRepository(ApplicationDbContext.Create())) { CustomersViewModel viewModel = new CustomersViewModel() { Customers = _customerRepo.All().ToList() }; return(View(viewModel)); } }
public IActionResult Index() { if (User.IsInRole(StringEnum.GetStringValue(RoleType.Admin))) { var customers = _customerRepository.All(); return(View(customers)); } else if (User.IsInRole(StringEnum.GetStringValue(RoleType.Staff))) { var userId = _userManager.GetUserId(User); var customers = _customerRepository.AllByStaffId(userId); return(View(customers)); } return(View()); }
public DashBoardSummaryDTO GetDashBoardSummary() { var numberOfUsers = UserRepository.All().Count(); var numberOfTickets = TicketRepository.GetTickets().Count(); var numberOfProjects = ProjectRepository.All().Count(); var numberOfCustomers = CustomerRepository.All().Count(); return(new DashBoardSummaryDTO() { TotalCustomers = numberOfCustomers, TotalProjects = numberOfProjects, TotalTickets = numberOfTickets, TotalUsers = numberOfUsers }); }
private static void CustomerLoadTestDynamic() { var customers = new CustomerRepository(); IEnumerable <dynamic> data; Stopwatch sw = Stopwatch.StartNew(); for (int i = 0; i < 1_000; i++) { data = customers.All(); } sw.Stop(); Console.WriteLine($"{nameof(CustomerLoadTestDynamic)} => {sw.ElapsedMilliseconds:N0}"); }
public ActionResult Index() { HomeViewModel viewModel = null; using (ICustomerRepository _customerRepo = new CustomerRepository(ApplicationDbContext.Create())) using (IEmployeeRepository _employeeRepo = new EmployeeRepository(ApplicationDbContext.Create())) using (IPostItRepository _postItRepo = new PostItRepository(ApplicationDbContext.Create())) { List <Template> templates = new List <Template>(); for (int i = 1; i < 3; i++) { Template template = new Template() { TemplateId = i, TemplateName = "Template - Uge " + i }; templates.Add(template); } var employees = _employeeRepo.All(); List <EmployeeHelpModel> employeeHelpModels = new List <EmployeeHelpModel>(); EmployeeHelpModel all = new EmployeeHelpModel() { Id = -1, Name = "Alle" }; employeeHelpModels.Add(all); foreach (var employee in employees) { EmployeeHelpModel helpModel = new EmployeeHelpModel() { Id = employee.EmployeeId, Name = employee.Name }; employeeHelpModels.Add(helpModel); } viewModel = new HomeViewModel() { Customers = _customerRepo.All().ToList(), Employees = employees.ToList(), EmployeesList2 = employeeHelpModels, Templates = templates }; } return(View(viewModel)); }
public async void GetsAllCustomers() { //Arrange var options = BuildInMemoryDb("GetsAllCustomers"); //Act using (var context = new ShoppingDbContext(options)) { var customer = new Customer { CustomerId = 1, FirstName = "Jim", LastName = "Bob", Email = "*****@*****.**" }; context.Add(customer); customer = new Customer { CustomerId = 2, FirstName = "Jane", LastName = "Doe", Email = "*****@*****.**" }; context.Add(customer); context.SaveChanges(); } //Assert using (var context = new ShoppingDbContext(options)) { var customerRepo = new CustomerRepository(context); var customers = await customerRepo.All(); Assert.Equal(2, customers.Count()); } }
public void Customers_Should_Be_Available() { var customers = _repo.All(); Assert.IsTrue(customers.Any()); }
public ActionResult Index() { return(this.Jsonp(CustomerRepository.All())); }
public ActionResult <IEnumerable <Customer> > GetAll() { return(new OkObjectResult(_customerRepository.All())); }
// GET: Customers public ActionResult Index() { return(View(_customerRepository.All())); }
public ActionResult Index() { return(View( _addressRepository.All().Where(c => !string.IsNullOrEmpty(c.FavouriteShopStreetText)) )); }