public async Task <IActionResult> OnGetAsync(int?id) { if (id == null) { return(NotFound()); } Post = await _postService.GetPostById(id); if (Post == null) { return(NotFound()); } ViewData["PostImage"] = Post.PostImage ?? "no-image.png"; Post.PostTitleInBrowser = TextConvertor.ReplaceLetters(Post.PostTitleInBrowser, '-', ' '); ViewData["GroupId"] = new SelectList(_groupService.GetAllGroup(), "GroupId", "GroupTitle"); //ViewData["Author"] = new SelectList(_userService.GetAllUsers(), "UserId", "UserName"); var tagsPost = ""; foreach (var tag in _postTagService.GetAllTagsByPostId(id)) { tagsPost += tag.Tag.TagTitle + ","; } ViewData["Tags"] = tagsPost.Length == 0 ? null : tagsPost.Substring(0, tagsPost.Length - 1); return(Page()); }
public IActionResult DeletePost(Guid guid) { if (getByIdUseCase.GetById(guid) == null) { return(BadRequest()); } var post = new Domain.Entities.Post.Post(guid); postRemoveUseCase.Remove(post); return(new OkObjectResult(post)); }
public IActionResult UpdatePost(Guid guid, string title, string description) { if (getByIdUseCase.GetById(guid) == null) { return(BadRequest()); } var post = new Domain.Entities.Post.Post(guid, title, description); postUpdateUseCase.Update(post); return(new OkObjectResult(post)); }
public IActionResult CreatePost(string title, string description) { var post = new Domain.Entities.Post.Post(title, description); var validationResult = new PostValidation().Validate(post); if (!validationResult.IsValid) { return(BadRequest(validationResult.Errors)); } var output = postAddUseCase.Add(post); return(new OkObjectResult(post)); }
public async Task <IActionResult> OnGetAsync(int?id) { if (id == null) { return(NotFound()); } Post = await _postService.GetPostById(id); if (Post == null) { return(NotFound()); } return(Page()); }
public async Task <IActionResult> OnPostAsync(int?id) { if (id == null) { return(NotFound()); } Post = await _postService.GetPostById(id); if (Post != null) { await _postService.RemovePost(id); } return(RedirectToPage("./Index")); }
public int Remove(Domain.Entities.Post.Post post) { return(postWriteOnlyRepository.Remove(post)); }
public int Add(Domain.Entities.Post.Post post) { return(postWriteOnlyRepository.Add(post)); }
public int Update(Domain.Entities.Post.Post post) { return(postWriteOnlyRepository.Update(post)); }