Ejemplo n.º 1
0
        public async Task <ActionResult> AddAsync(ShopCommentViewModel shopComment)
        {
            shopComment.AddedById = _claimsGetter.UserId(User?.Claims);
            await _shopCommentsService.SaveAsync(shopComment);

            return(NoContent());
        }
Ejemplo n.º 2
0
        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 }));
            }
        }
Ejemplo n.º 3
0
        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 }));
            }
        }
Ejemplo n.º 4
0
 private Task AddShopComment(ShopCommentViewModel viewModel)
 => _mediator.Send(new AddShopCommentCommand
 {
     Rating        = viewModel.Rating,
     Text          = viewModel.Text,
     AddedByUserId = viewModel.AddedById,
     ShopId        = viewModel.ShopId,
 });
Ejemplo n.º 5
0
        public async Task EditAsync_Calls_ShopCommentsService()
        {
            //Arrange
            var shopComment = new ShopCommentViewModel();

            //Act
            await _shopCommentsController.EditAsync(shopComment);

            //Assert
            _mockShopCommentsService.Verify(x => x.SaveAsync(shopComment));
        }
Ejemplo n.º 6
0
        public async Task AddAsync_Calls_ShopCommentsService()
        {
            //Arrange
            var category = new ShopCommentViewModel();

            //Act
            await _shopCommentsController.AddAsync(category);

            //Assert
            _mockShopCommentsService.Verify(x => x.SaveAsync(category));
        }
Ejemplo n.º 7
0
        public async Task <ActionResult> EditAsync(ShopCommentViewModel shopComment)
        {
            await _shopCommentsService.SaveAsync(shopComment);

            return(NoContent());
        }
Ejemplo n.º 8
0
 private Task EditShopComment(ShopCommentViewModel viewModel)
 => _mediator.Send(new EditShopCommentCommand
 {
     Id   = viewModel.Id,
     Text = viewModel.Text
 });
Ejemplo n.º 9
0
 public Task SaveAsync(ShopCommentViewModel viewModel)
 => viewModel.Id == 0 ? AddShopComment(viewModel) : EditShopComment(viewModel);