예제 #1
0
        // GET: ReportLogs
        public async Task <ActionResult> Index(string searchKey)
        {
            var userDepartment = await _userDepartmentsService.GetUserDepartmentsAsync(User.Identity.GetUserId());

            var departments = userDepartment as IList <Department> ?? userDepartment.ToList();
            var employess   = await _employeesService.FindEmployessesByDateAsync(DateTime.Now);

            if (!string.IsNullOrEmpty(searchKey))
            {
                try
                {
                    DateTime dateSearch = DateTime.ParseExact(searchKey, "dd/MM/yyyy", CultureInfo.InvariantCulture);
                    employess = await _employeesService.FindEmployessesByDateAsync(dateSearch, departments);
                }
                catch (Exception ex)
                {
                    ViewBag.ErrorMessage = $"Invalid date {searchKey}." + ex.Message;
                }
            }
            else
            {
                foreach (var dept in departments)
                {
                    employess = employess.Where(item => item.DepartmentID == dept.DepartmentID);
                }
            }
            return(View(employess));
        }
예제 #2
0
        //
        // GET: /Account/Index
        public async Task <ActionResult> Index(ManageMessageId?message)
        {
            ViewBag.StatusMessage =
                message == ManageMessageId.ChangePasswordSuccess ? "Your password has been changed."
                : message == ManageMessageId.SetPasswordSuccess ? "Your password has been set."
                : message == ManageMessageId.SetTwoFactorSuccess ? "Your two factor provider has been set."
                : message == ManageMessageId.Error ? "An error has occurred."
                : message == ManageMessageId.AddPhoneSuccess ? "The phone number was added."
                : message == ManageMessageId.RemovePhoneSuccess ? "Your phone number was removed."
                : "";

            var model = new IndexViewModel
            {
                HasPassword       = HasPassword(),
                PhoneNumber       = await UserManager.GetPhoneNumberAsync(User.Identity.GetUserId()),
                TwoFactor         = await UserManager.GetTwoFactorEnabledAsync(User.Identity.GetUserId()),
                Logins            = await UserManager.GetLoginsAsync(User.Identity.GetUserId()),
                BrowserRemembered = await AuthenticationManager.TwoFactorBrowserRememberedAsync(User.Identity.GetUserId())
            };
            var departments = await _userDepartmentsService.GetUserDepartmentsAsync(User.Identity.GetUserId());

            ViewBag.UserDepartments = departments.Select(u => u.Name).ToList();
            return(View(model));
        }
예제 #3
0
        public async Task <ActionResult> Index(SearchBarcode model)
        {
            if (ModelState.IsValid)
            {
                var userDepartment = await _userDepartmentsService.GetUserDepartmentsAsync(User.Identity.GetUserId());

                var user = await _bioStarService.GetUserById(model.SearchKey);

                if (user != null)
                {
                    var departments = userDepartment as IList <Department> ?? userDepartment.ToList();
                    var employes    = new Employess()
                    {
                        StaffCode       = user.sUserID,
                        FullName        = user.sUserName,
                        DepartmentID    = departments.First().DepartmentID,
                        DateCheck       = DateTime.Now,
                        LeaderApproved  = false,
                        ManagerApproved = false,
                        GaComplete      = false,
                        Note            = StringHelper.GetInfo(User.Identity.GetUserName()),
                    };
                    try
                    {
                        var employesCheck = await _employeesService.GetEmployessByIdAndDateAsync(model.SearchKey, DateTime.Now, departments.First().DepartmentID);

                        if (employesCheck == null)
                        {
                            await _employeesService.CreateAsync(employes);

                            model = new SearchBarcode()
                            {
                                SearchKey = string.Empty,
                            };
                            ModelState.Clear();
                            return(View(model));
                        }
                        model = new SearchBarcode()
                        {
                            SearchKey = string.Empty,
                        };
                        ModelState.Clear();
                        ModelState.AddModelError("SearchKey", "Error!");
                        return(View(model));
                    }
                    catch (Exception ex)
                    {
                        model = new SearchBarcode()
                        {
                            SearchKey = string.Empty,
                        };
                        ModelState.Clear();
                        ModelState.AddModelError("SearchKey", ex.Message);
                        return(View(model));
                    }
                }
                model = new SearchBarcode()
                {
                    SearchKey = string.Empty,
                };
                ModelState.Clear();
                ModelState.AddModelError("SearchKey", "Error! User not exits.");
                return(View(model));
            }
            return(View(model));
        }