Пример #1
0
        public async Task <IActionResult> GetCustomerDay(string EmpSearch, EmployeesModel employeesModel)
        {
            var userId = this.User.FindFirstValue(ClaimTypes.NameIdentifier);

            employeesModel = _context.Employees.Where(e => e.IdentityUserId == userId).SingleOrDefault();
            DateTime dateTime = DateTime.Now;
            var      date     = dateTime.ToString("dddd");

            ViewData["GetCustomerDay"] = EmpSearch;

            try
            {
                var empquery = _context.Customers.Where(c => c.ZipCode == employeesModel.ZipCode && c.SuspendService != true || c.OneTimeDate == dateTime).ToList();
                empquery.RemoveAll(d => d.SuspendStart <= dateTime || d.SuspendEnd >= dateTime);
                if (!String.IsNullOrEmpty(EmpSearch))
                {
                    EmpSearch = DayOfWeekFormatter.FormatDay(EmpSearch);
                    empquery  = empquery.Where(x => x.PickUpDay.Contains(EmpSearch)).ToList();
                }
                return(View(empquery));
            }
            catch
            {
                return(View("Index"));
            }
        }
Пример #2
0
        public ActionResult CustomerPickUp(CustomersModel customersModel)
        {
            try
            {
                var userId   = this.User.FindFirstValue(ClaimTypes.NameIdentifier);
                var customer = _context.Customers.Where(c => c.IdentityUserId == userId).SingleOrDefault();

                string formattedDay = DayOfWeekFormatter.FormatDay(customersModel.PickUpDay);
                customer.PickUpDay = formattedDay;

                _context.SaveChanges();
                return(RedirectToAction(nameof(Index)));
            }
            catch
            {
                return(RedirectToAction(nameof(Index)));
            }
        }