Ejemplo n.º 1
0
        public async Task <IActionResult> Select(CustomersDayFilter cdf)
        {
            var applicationDbContext = _context.Employee.Include(e => e.IdentityUser);

            var userId = this.User.FindFirstValue(ClaimTypes.NameIdentifier);

            var loggedInEmployee = _context.Employee.Where(e => e.IdentityUserId == userId).SingleOrDefault();

            var customerInZipcode = _context.customers.Where(c => c.ZipCode == loggedInEmployee.ZipCode).ToList();

            var customerPickUpDay = cdf.DaySelection;

            cdf.Customers = customerInZipcode.Where(c => c.Day.ToString() == customerPickUpDay).ToList();
            //to ensurelog in
            var loggedInEmployee2 = _context.Employee.Where(c => c.IdentityUserId == userId).Include(c => c.IdentityUser);

            ViewData["EmployeeExists"] = loggedInEmployee2.Count() == 1;

            return(View("Index", cdf));
        }
Ejemplo n.º 2
0
        // GET: Employees
        public async Task <IActionResult> Index()
        {
            CustomersDayFilter cdf = new CustomersDayFilter();

            var applicationDbContext = _context.Employee.Include(e => e.IdentityUser);

            var userId = this.User.FindFirstValue(ClaimTypes.NameIdentifier);

            var loggedInEmployee = _context.Employee.Where(e => e.IdentityUserId == userId).SingleOrDefault();

            var customerInZipcode = _context.customers.Where(c => c.ZipCode == loggedInEmployee.ZipCode).ToList();

            var today = DateTime.Now.DayOfWeek.ToString();

            // string test = customerInZipcode[0].Day.ToString();

            cdf.Customers = customerInZipcode.Where(c => c.Day.ToString() == today).ToList();

            var loggedInEmployee2 = _context.Employee.Where(c => c.IdentityUserId == userId).Include(c => c.IdentityUser);

            ViewData["EmployeeExists"] = loggedInEmployee2.Count() == 1;

            return(View(cdf));
        }