public async Task <IActionResult> NewPost(CreatePostCommand command) { if (!ModelState.IsValid) { ViewBag.ShowMessage = true; ViewBag.Message = "Something went wrong"; return(View()); } try { CreatePostValidation.CommandValidation(command); var admin = await _adminService.GetAdminAsync(); await _postService.AddPostAsync(command, admin); ViewBag.Added = true; return(View()); } catch (InternalSystemException ex) { ViewBag.ShowMessage = true; ViewBag.Message = ex.Message; return(View()); } catch (Exception) { ViewBag.ShowMessage = true; ViewBag.Message = "Something went wrong!"; return(View()); } }
public EfCreatePostsCommand(ProjekatContext context, CreatePostValidation validator) { _context = context; _validator = validator; }