public LogicResponse Edit(ModuleDto moduleDto) { LogicResponse response = new LogicResponse(); Course course = _courseRepository.GetById(moduleDto.CourseId); if (course == null) { response.Success = false; response.Message = "No se encontró el curso del módulo a modificar"; return(response); } Module module = _moduleRepository.Get(moduleDto.CourseId, moduleDto.Id); if (module == null) { response.Success = false; response.Message = "No se encontró el módulo"; return(response); } module = _mapper.Map <ModuleDto, Module>(moduleDto); try { _moduleRepository.Edit(module); response.Success = true; response.Message = module.Id.ToString(); return(response); } catch (Exception ex) { response.Success = false; response.Message = "Error al almacenar el módulo"; return(response); } }
public IHttpActionResult PostModule(int id, Module module) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != module.ID) { return(BadRequest()); } bool result = repository.Edit(module); if (!result) { return(BadRequest()); } module = repository.GetById(id); return(Content(HttpStatusCode.OK, module)); }
public IActionResult EditModule(Module module) { moduleRepo.Edit(module); return(RedirectToAction("Edit", "QUESTORs", new { id = module.QUESTORId })); }