示例#1
0
        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);
            }
        }
示例#2
0
        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));
        }
示例#3
0
 public IActionResult EditModule(Module module)
 {
     moduleRepo.Edit(module);
     return(RedirectToAction("Edit", "QUESTORs", new { id = module.QUESTORId }));
 }