public async Task <ActionResult> AddAsync(ShopCommentViewModel shopComment) { shopComment.AddedById = _claimsGetter.UserId(User?.Claims); await _shopCommentsService.SaveAsync(shopComment); return(NoContent()); }
public ActionResult CreateShopFeedback(ShopCommentViewModel commentViewModel) { if (ModelState.IsValid) { try { _shopService.ShopFeedbackCreate(new Data.Entities.ShopFeedback { Comment = commentViewModel.Comment, ShopID = commentViewModel.ShopId, CreatedAt = DateTime.Now, UserID = WebSecurity.CurrentUserId }); } catch (DataException) { TempData["error"] = ProjectConfiguration.Get.DataErrorMessage; } return(RedirectToAction("Details", "Shops", new { id = commentViewModel.ShopId })); } else { TempData["Comment"] = commentViewModel.Comment; return(RedirectToAction("Details", "Shops", new { id = commentViewModel.ShopId })); } }
public ActionResult Create(ShopCommentViewModel commentViewModel) { if (ModelState.IsValid) { ShopComment comment = new ShopComment() { Id = commentViewModel.CommentId, ShopId = commentViewModel.ShopId, Comment = commentViewModel.Comment, CreatedAt = DateTime.Now, IsActive = true, UserId = WebSecurity.CurrentUserId }; try { _shopCommentRepository.Save(comment); } catch (DataException) { TempData["error"] = ProjectConfiguration.Get.DataErrorMessage; } return(RedirectToAction("Details", "Shop", new { Id = comment.ShopId })); } else { TempData["Comment"] = commentViewModel.Comment; return(RedirectToAction("Details", "Shop", new { Id = commentViewModel.ShopId })); } }
private Task AddShopComment(ShopCommentViewModel viewModel) => _mediator.Send(new AddShopCommentCommand { Rating = viewModel.Rating, Text = viewModel.Text, AddedByUserId = viewModel.AddedById, ShopId = viewModel.ShopId, });
public async Task EditAsync_Calls_ShopCommentsService() { //Arrange var shopComment = new ShopCommentViewModel(); //Act await _shopCommentsController.EditAsync(shopComment); //Assert _mockShopCommentsService.Verify(x => x.SaveAsync(shopComment)); }
public async Task AddAsync_Calls_ShopCommentsService() { //Arrange var category = new ShopCommentViewModel(); //Act await _shopCommentsController.AddAsync(category); //Assert _mockShopCommentsService.Verify(x => x.SaveAsync(category)); }
public async Task <ActionResult> EditAsync(ShopCommentViewModel shopComment) { await _shopCommentsService.SaveAsync(shopComment); return(NoContent()); }
private Task EditShopComment(ShopCommentViewModel viewModel) => _mediator.Send(new EditShopCommentCommand { Id = viewModel.Id, Text = viewModel.Text });
public Task SaveAsync(ShopCommentViewModel viewModel) => viewModel.Id == 0 ? AddShopComment(viewModel) : EditShopComment(viewModel);