// GET: ServicesEmployees
        public IActionResult Index(int?idEmployee)
        {
            if (TempData["Error"] != null && !String.IsNullOrEmpty(TempData["Error"].ToString()))
            {
                ModelState.AddModelError("Error", TempData["Error"].ToString());
            }
            TempData.Clear();


            string responseBodyServicesEmployeeList          = this._clientService.GetResponse(this._configuration["AppSettings:ApiRest"] + "api/ServiceEmployeeApi").GetAwaiter().GetResult();
            List <ServiceEmployeeDto> serviceEmployeeListDto = JsonConvert.DeserializeObject <List <ServiceEmployeeDto> >(responseBodyServicesEmployeeList);
            var servicesEmployeesList = serviceEmployeeListDto.Where(elem => elem.IdEmployee == idEmployee);

            string            responseBodyServiceList = this._clientService.GetResponse(this._configuration["AppSettings:ApiRest"] + "api/ServiceApi").GetAwaiter().GetResult();
            List <ServiceDto> serviceDto = JsonConvert.DeserializeObject <List <ServiceDto> >(responseBodyServiceList);

            ViewData["IdService"] = new SelectList(serviceDto, "Id", "Name");
            ServiceEmployeeModel serviceEmployeeModel = new ServiceEmployeeModel();

            serviceEmployeeModel.ServicesEmployeesList = servicesEmployeesList;
            serviceEmployeeModel.ServiceEmployee       = new ServiceEmployeeDto();

            string      responseBodyEmployee = this._clientService.GetResponse(this._configuration["AppSettings:ApiRest"] + "api/EmployeeApi/" + idEmployee.Value).GetAwaiter().GetResult();
            EmployeeDto employeeDto          = JsonConvert.DeserializeObject <EmployeeDto>(responseBodyEmployee);

            serviceEmployeeModel.ServiceEmployee.IdEmployeeNavigation = employeeDto;
            serviceEmployeeModel.ServiceEmployee.IdEmployee           = idEmployee.Value;
            return(View(serviceEmployeeModel));
        }
        public ServiceEmployeeModel GetIndexServiceEmployeeMonolithic()
        {
            int idEmployee            = 22;
            var servicesEmployeesList = _context.ServicesEmployees.Where(elem => elem.IdEmployee == idEmployee).Include(s => s.IdEmployeeNavigation).Include(s => s.IdServiceNavigation);

            ServiceEmployeeModel serviceEmployeeModel = new ServiceEmployeeModel();

            serviceEmployeeModel.ServicesEmployeesList = servicesEmployeesList;
            serviceEmployeeModel.ServiceEmployee       = new ServicesEmployees();
            serviceEmployeeModel.ServiceEmployee.IdEmployeeNavigation = _context.Employees.FirstOrDefault(elem => elem.Id == idEmployee);
            serviceEmployeeModel.ServiceEmployee.IdEmployee           = idEmployee;
            return(serviceEmployeeModel);
        }
        public async Task <IActionResult> Create(ServiceEmployeeModel serviceEmployeeModel)
        {
            ServiceEmployeeDto serviceEmployee = new ServiceEmployeeDto();

            serviceEmployee.IdEmployee = serviceEmployeeModel.ServiceEmployee.IdEmployee;
            serviceEmployee.IdService  = serviceEmployeeModel.ServiceEmployee.IdService;

            string responseBodyServicesEmployeeList          = this._clientService.GetResponse(this._configuration["AppSettings:ApiRest"] + "api/ServiceEmployeeApi").GetAwaiter().GetResult();
            List <ServiceEmployeeDto> serviceEmployeeListDto = JsonConvert.DeserializeObject <List <ServiceEmployeeDto> >(responseBodyServicesEmployeeList);


            if (serviceEmployeeListDto.FirstOrDefault(elem => elem.IdEmployee == serviceEmployee.IdEmployee && elem.IdService == serviceEmployee.IdService) != null)
            {
                TempData["Error"] = "This services is assigned";
                return(RedirectToAction(nameof(Index), new
                {
                    idEmployee = serviceEmployee.IdEmployee
                }));
            }
            if (serviceEmployeeModel.ServiceEmployee.IdService != 0)
            {
                string responseBodyServicesEmployee = await this._clientService.PostResponse(this._configuration["AppSettings:ApiRest"] + "api/ServiceEmployeeApi", JsonConvert.SerializeObject(serviceEmployee));

                ServiceEmployeeDto employeeDto = JsonConvert.DeserializeObject <ServiceEmployeeDto>(responseBodyServicesEmployee);
                return(RedirectToAction(nameof(Index), new
                {
                    idEmployee = serviceEmployee.IdEmployee
                }));
            }

            string            responseBodyServicesList = this._clientService.GetResponse(this._configuration["AppSettings:ApiRest"] + "api/ServiceApi").GetAwaiter().GetResult();
            List <ServiceDto> serviceDto = JsonConvert.DeserializeObject <List <ServiceDto> >(responseBodyServicesList);

            ViewData["IdService"] = new SelectList(serviceDto, "Id", "Name", serviceEmployee.IdService);
            return(RedirectToAction(nameof(Index), new
            {
                idEmployee = serviceEmployee.IdEmployee
            }));
        }