// GET: PricingDetails/Details/5
        public async Task <IActionResult> Details(int?id)
        {
            GetSessions();

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

            if (id == null)
            {
                return(NotFound());
            }

            var pricingDetails = await _context.PricingDetails
                                 .FirstOrDefaultAsync(m => m.Id == id);

            var hiring = await _context.Hiring.ToListAsync();

            var viewModel = new PricingFormViewModel {
                PricingDetails = pricingDetails, Hiring = hiring
            };

            if (pricingDetails == null)
            {
                return(NotFound());
            }

            return(View(viewModel));
        }
        // GET: Pricings/Create
        public async Task <IActionResult> Create()
        {
            GetSessions();

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

            int empId       = ViewBag.Id;
            var accessLevel = ViewBag.AcessLevel;

            var listPricing = await _pricingService.FindAllAsync(null, null, null, null, null, null, null);

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

            var managers = await _employeeService.FindAllManagersAsync();

            var funcionarios = await _employeeService.FindEmployeesActivesAsync();

            var pricingType = await _context.PricingType.ToListAsync();

            var viewModel = new PricingFormViewModel {
                ListPricing = listPricing, Clients = clientes, Employees = funcionarios, Managers = managers, PricingType = pricingType
            };

            return(View(viewModel));
        }
        // GET: PricingDetails/Create
        public async Task <IActionResult> Create()
        {
            GetSessions();

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

            var pricingDetails = _pricingService.PricingDetails();
            var hiring         = await _context.Hiring.ToListAsync();

            var viewModel = new PricingFormViewModel {
                Hiring = hiring
            };

            return(View(viewModel));
        }
        // GET: Pricings
        public async Task <IActionResult> Index(int?tipoPrecificacao, int?clients, int?executivoConta, int?alocacaoGerente, int?responsavel, DateTime?dtInicial, DateTime?dtFinal)
        {
            GetSessions();

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

            int empId       = ViewBag.Id;
            var accessLevel = ViewBag.AcessLevel;

            ViewBag.tipoPrecificacao = tipoPrecificacao;
            ViewBag.clients          = clients;
            ViewBag.executivoConta   = executivoConta;
            ViewBag.alocacaoGerente  = alocacaoGerente;
            ViewBag.responsavel      = responsavel;

            if (dtInicial.HasValue)
            {
                ViewBag.dtInicial = dtInicial.Value.ToShortDateString();
            }

            if (dtFinal.HasValue)
            {
                ViewBag.dtFinal = dtFinal.Value.ToShortDateString();
            }

            var listPricing = await _pricingService.FindAllAsync(tipoPrecificacao, clients, executivoConta, alocacaoGerente, responsavel, dtInicial, dtFinal);

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

            var managers = await _employeeService.FindAllManagersAsync();

            var funcionarios = await _employeeService.FindDifferenceEmployeeAsync();

            var pricingType = await _context.PricingType.ToListAsync();

            var viewModel = new PricingFormViewModel {
                ListPricing = listPricing, Clients = clientes, Employees = funcionarios, Managers = managers, PricingType = pricingType
            };

            return(View(viewModel));
        }
        // GET: Pricings/Edit/5
        public async Task <IActionResult> Edit(int?id)
        {
            GetSessions();

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

            if (id == null)
            {
                return(NotFound());
            }

            GetSessions();

            int empId       = ViewBag.Id;
            var accessLevel = ViewBag.AcessLevel;

            var pricing = await _context.Pricing.FindAsync(id);

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

            var managers = await _employeeService.FindAllManagersAsync();

            var funcionarios = await _employeeService.FindEmployeesActivesAsync();

            var pricingType = await _context.PricingType.ToListAsync();

            var viewModel = new PricingFormViewModel {
                Pricing = pricing, Clients = clientes, Employees = funcionarios, Managers = managers, PricingType = pricingType
            };

            if (pricing == null)
            {
                return(NotFound());
            }
            return(View(viewModel));
        }