public async Task <IActionResult> EditBlog(EditPostModel model) { var newUrl = UploadedFile(model); if (ModelState.IsValid) { try { await model.EditBlogAsync(newUrl); var msg = "Congrats! Editted Blog Successfully"; _logger.LogInformation("Blog Editted Successfully"); model.Response = new ResponseModel(msg, ResponseType.Success); return(RedirectToAction("Index")); } catch (Exception ex) { var msg = "Failed to Edit Blog"; model.Response = new ResponseModel(msg, ResponseType.Failure); _logger.LogError(ex.Message); } } model.Categories = model.GetAllCategoryForSelectAsync(); return(View(model)); }
public async Task <IActionResult> EditBlog(int id) { var model = new EditPostModel(); await model.LoadByIdAsync(id); model.Categories = model.GetAllCategoryForSelectAsync(); return(View(model)); }