public async Task <IActionResult> OnPostAsync() { if (!ModelState.IsValid) { return(Page()); } await blogService.AddOrUpdateAsync(Category); return(LocalRedirect("/Admin/Categories")); }
public async Task <IActionResult> Post([CustomizeValidator(RuleSet = "BlogAddOrUpdate")] BlogDTO blogDTO) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } try { var blog = mapper.Map <Blog>(blogDTO); blog.OwnerId = LoggedInUserId; blog = await blogService.AddOrUpdateAsync(blog); blogDTO = mapper.Map <BlogDTO>(blog); } catch { throw new BlogSystemException("There's been an error while trying to add the blog entry"); } return(Ok(blogDTO)); }