public IActionResult Paln(int id)
        {
            var currentAdv  = _advertisementPlanService.GetAdvertisementService(id);
            var currentPage = _pageService.GetPage(currentAdv.PageId);
            AdvertisementViewModel model = new AdvertisementViewModel();

            model.Title       = currentAdv.User.Account.FullName;
            model.Picture     = currentPage.Logo;
            model.Tages       = currentAdv.Advertisement_Tags.ToList();
            model.Viewer      = currentAdv.MinViewerInDay;
            model.Description = currentAdv.Description;
            model.Id          = currentAdv.Id;
            model.Comments    = _commentService.AdvertisementComments(id);
            model.Tages       = currentAdv.Advertisement_Tags.ToList();
            return(View(model));
        }
Пример #2
0
        public IActionResult AddToCart(AddToCartViewModel model)
        {
            List <CartServiceViewModel> cartServiceViewModels = new List <CartServiceViewModel>();
            var cartCookie = _cookieHelper.GetCookie("_cart");

            if (cartCookie != null)
            {
                cartServiceViewModels = (List <CartServiceViewModel>)cartCookie;
            }
            if (cartServiceViewModels.Count > 100)
            {
                return(new JsonResult(new ApiResultViewModel {
                    Data = null, Message = "سبد بیش از حد مجاز پر شده است", Status = false
                }));
            }
            if (cartServiceViewModels.Any(x => x.Id == model.Id && x.TypeOfService == model.TypeOfService))
            {
                cartServiceViewModels.Where(x => x.Id == model.Id && x.TypeOfService == model.TypeOfService).Select(x => { x.Count = x.Count + 1; return(x); }).ToList();
            }
            else
            {
                dynamic service = null;
                if (model.TypeOfService == TypeOfServiceEnum.AdvertisementService)
                {
                    service = _advertisementPlanService.GetAdvertisementService(model.Id);
                }
                if (model.TypeOfService == TypeOfServiceEnum.GraphicService)
                {
                    service = _graphicDesigningPlanService.GetGraphicDesigningPlan(model.Id);
                }
                if (service != null)
                {
                    cartServiceViewModels.Add(new CartServiceViewModel()
                    {
                        Count = 1, Id = model.Id, TypeOfService = model.TypeOfService, Title = service.Title, Price = service.Price.ToString()
                    });
                }
            }
            _cookieHelper.SetCookie("_cart", cartServiceViewModels, 7);
            return(new JsonResult(new ApiResultViewModel {
                Data = null, Message = "سبد خرید بروزرسانی شد", Status = true
            }));
        }