public async Task <ActionResult> EditHorario(int?id)
        {
            if (id == null)
            {
                return(Content("Debe incluir el id"));
            }

            try
            {
                var horarioConsultaTask = _horarioConsultaEndpoint.Get(id, _userSession.BearerToken);
                var materiasTask        = _materiaEndpoint.GetAll(_userSession.BearerToken);

                await Task.WhenAll(horarioConsultaTask, materiasTask);

                var horarioConsulta = _mapper.Map <MvcHorarioConsultaModel>(source: horarioConsultaTask.Result);
                var materias        = _mapper.Map <IEnumerable <MvcMateriaModel> >(source: materiasTask.Result);

                var viewModel = new EditOwnHorarioConsultaViewModel(horarioConsulta: horarioConsulta, materias: materias);

                return(PartialView("_EditOwnHorario", viewModel));
            }
            catch (UnauthorizedRequestException)
            {
                return(RedirectToAction("AccessDenied", "Error"));
            }
            catch (NotFoundRequestException ex)
            {
                return(Content($"{ex.StatusCode}: Elemento no encontrado"));
            }
            catch (Exception ex)
            {
                return(RedirectToAction("SpecificError", "Error", new { error = ex.Message }));
            }
        }
        public async Task <ActionResult> EditHorario(EditOwnHorarioConsultaViewModel viewModel)
        {
            try
            {
                Usuario user = await _usuarioEndpoint.GetCurrentUsuario(_userSession.BearerToken);

                viewModel.SetProfesor(user.Id);

                var entity = _mapper.Map <HorarioConsulta>(viewModel.HorarioConsulta);

                await _horarioConsultaEndpoint.Put(entity, _userSession.BearerToken);
            }
            catch (UnauthorizedRequestException)
            {
                return(RedirectToAction("AccessDenied", "Error"));
            }
            catch (BadRequestException ex)
            {
                var materiasTask = _materiaEndpoint.GetAll(_userSession.BearerToken); // May throw an exception, so that is why the modal is not showing in nico user

                await Task.WhenAll(materiasTask);

                var materias = _mapper.Map <IEnumerable <MvcMateriaModel> >(source: materiasTask.Result);

                viewModel.SetMateriasAsSelectList(materias);
                viewModel.SetDiasSemanaAsSelectList();

                ModelState.AddModelErrors(ex.Errors);

                return(PartialView("_EditOwnHorario", viewModel));
            }
            catch (Exception ex)
            {
                return(RedirectToAction("SpecificError", "Error", new { error = ex.Message }));
            }

            return(Content("OK"));
        }