public async Task <IActionResult> Edit(EditDesafioViewModel model) { try { var profId = _userService.Get_ProfesorId(User.Claims); var res = await _ctrlService.Edit_Desafio(profId, model); if (res) { this.SetAlerts("success-alerts", "Cambios guardados exitosamente"); } else { this.SetAlerts("error-alerts", "No se pudieron guardar los cambios"); } return(RedirectToAction("Details", new { desafioId = model.Id })); } catch (ApplicationServicesException) { ModelState.AddModelError("", "Error al editar " + "desafío revisa tus datos"); return(View(model)); } }
public async Task <bool> Edit_Desafio(int profId, EditDesafioViewModel model) { if (!await _data.Exist_DesafioP(model.Id, profId)) { throw new ApplicationServicesException(); } var desafio = await _data.Find_Desafio(model.Id); desafio.Nombre = model.Nombre; desafio.Descripcion = model.Descripcion; desafio.DirDesafioInicial = model.UrlEscenarioInicial; _data.Edit(desafio); return(await _data.SaveAllAsync()); }