예제 #1
0
        public async Task <IActionResult> ModeAdmin(int?month, int?year)
        {
            GetSessions();

            if (ViewBag.Email == null)
            {
                return(ExpiredSession());
            }


            try
            {
                var result = await _hourService.FindAllAsync(month, year);

                return(View("ModeAdmin", result));
            }
            catch (DbConcurrencyException e)
            {
                return(RedirectToAction(nameof(Error), new { message = e.Message }));
            }
            catch (Exception e)
            {
                return(RedirectToAction(nameof(Error), new { message = "Erro não definido, tentar novamente e avisar o suporte" }));
            }
        }
        public async Task <IActionResult> Index(int?Selectbilling, int?approval, int?description, int?clients, int?projects, int?employees, int?month, int?year)
        {
            GetSessions();

            if (ViewBag.Email == null)
            {
                return(ExpiredSession());
            }

            try
            {
                ViewBag.Month       = month;
                ViewBag.Year        = year;
                ViewBag.Billing     = Selectbilling;
                ViewBag.Approval    = approval;
                ViewBag.Description = description;
                ViewBag.Clients     = clients;
                ViewBag.Projects    = projects;
                ViewBag.Employees   = employees;

                int empId       = ViewBag.Id;
                var accessLevel = ViewBag.AcessLevel;
                //var result = await _hourService.FindAllAsync(month, year);
                var horas = await _hourService.FindAllAsync(Selectbilling, approval, description, clients, projects, employees, month, year, empId, accessLevel);

                var clientes = await _clientService.FindAllAsync(accessLevel, empId);

                var projetos = await _projectService.FindProjectAsync(empId, accessLevel);

                var funcionarios = await _employeeService.FindAllAsync();

                var Description = await _context.Description.Where(x => x.Active == 1).ToListAsync();

                var localities = await _context.Locality.Where(x => x.Active == 1).ToListAsync();

                var status = await _hourService.FindStatus("horas");

                //var funcionarios = await _employeeService.FindAllAsync();
                var viewModel = new HourFormViewModel {
                    Hours = horas, Projects = projetos, Clients = clientes, Employees = funcionarios, Description = Description, Locality = localities, Status = status
                };

                return(View(viewModel));
            }
            catch (Exception e)
            {
                return(RedirectToAction(nameof(Error), new { message = e.Message }));
            }
        }