public async Task <bool> Edit_DesafioInicial(int profId, ChangeStarterViewModel model) { try { if (!await _data.Exist_Profesor_Curso(profId, model.CursoId)) { return(false); } if (!await _data.Exist_Desafio(model.NewStarterId, model.CursoId) && !await _data.Exist_Desafio(model.OldStarterId, model.CursoId)) { throw new ApplicationServicesException( "Error al cambiar el desafío"); } await _data.ChangeStarterDesafio(model.CursoId, model.OldStarterId, model.NewStarterId); return(await _data.SaveAllAsync()); } catch (Exception e) { Console.WriteLine(e); throw new ApplicationServicesException( "Error en la eliminación de desafío", e); } }
public async Task <IActionResult> ChangeStarter( ChangeStarterViewModel model) { try { if (ModelState.IsValid) { var profId = _userService.Get_ProfesorId(User.Claims); var res = await _ctrlService .Edit_DesafioInicial(profId, model); if (res) { this.SetAlerts("success-alerts", "Desafío inicial " + "cambiado exitosamente"); } } else { this.SetAlerts("error-alerts", "No es posible" + " cambiar el desafío"); } } catch (ApplicationServicesException e) { this.SetAlerts("error-alerts", e.Message); } return(RedirectToAction("Details", "ProfesorCurso", new { idCurso = model.CursoId })); }