public IActionResult BlockEdit(BlockEditDTO blockEdit) { _loggerManager.Info($"BlockEdit() was requested"); ViewData["Step"] = blockEdit.Step; if (ModelState.IsValid) { var result = _planRepository.UpdateBlock(blockEdit, HttpContext.GetUserId()); if (!result) { ModelState.AddModelError(string.Empty, sharedResource.manageServerError); _loggerManager.Warn($"BlockEdit() was unable to update a block"); } else { ViewData["SuccessMessage"] = "Block successfully updated"; _loggerManager.Warn($"BlockEdit() successfully updated"); } } else { _loggerManager.Warn($"BlockEdit() was invalid"); } return(View("BlockEdit", blockEdit)); }
public IActionResult BlockEdit(int id) { _loggerManager.Info($"BlockEdit({id}) was requested"); var block = _planRepository.GetBlock(id); if (block == null) { _loggerManager.Warn($"BlockEdit({id}): A block was not found"); return(BadRequest()); } ViewData["Step"] = block.Step; var blockEdit = new BlockEditDTO { Description = block.Description, Id = block.Id, Instruction = block.Instruction, Title = block.Title, Step = block.Step }; _loggerManager.Info($"BlockEdit({id}): A block was successfully found"); return(View("BlockEdit", blockEdit)); }