public async void Create()
        {
            ErrorMessages = null;

            var materia = new WpfMateriaModel {
                Name           = NameInForm, Year = YearInForm, IsElectiva = IsElectivaInForm,
                DepartamentoId = SelectedDepartamento?.Id
            };

            try {
                var entity = _mapper.Map <Materia>(materia);

                await _materiaEndpoint.Post(entity, _usuarioLogged.Token);
                await LoadMaterias();

                SelectedMateria = null;
            }
            catch (UnauthorizedRequestException)
            {
                ErrorMessages = new BindingList <string> {
                    "No tiene acceso"
                };
            }
            catch (BadRequestException ex)
            {
                ErrorMessages = new BindingList <string>(ex.Errors.Select(kvp => string.Join(". ", kvp.Value)).ToList());
            }
            catch (Exception ex)
            {
                ErrorMessages = new BindingList <string> {
                    $"{ex.Message} Ha ocurrido un error. Por favor contacte a soporte"
                };
            }
        }
        public async Task <ActionResult> Create(CreateMateriaViewModel viewModel)
        {
            try
            {
                var entity = _mapper.Map <Materia>(viewModel.Materia);

                await _materiaEndpoint.Post(entity, _userSession.BearerToken);
            }
            catch (UnauthorizedRequestException)
            {
                return(RedirectToAction("AccessDeniedPartial", "Error"));
            }
            catch (BadRequestException ex)
            {
                IEnumerable <Departamento> entities = await _departamentoEndpoint.GetAll(_userSession.BearerToken);

                var departamentos = _mapper.Map <IEnumerable <MvcDepartamentoModel> >(entities);

                viewModel.SetDepartamentosAsSelectList(departamentos);

                ModelState.AddModelErrors(ex.Errors);

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

            return(Content("OK"));
        }