public ActionResult _partialGoodsEditor(long?goodId, bool isClone)
        {
            var store = new StoreAction();
            var model = new Good();

            if (goodId > 0)
            {
                model        = store.GetGoodInfo(goodId.Value);
                model.isEdit = true;
            }
            if (isClone)
            {
                model.id     = 0;
                model.isEdit = false;
                model.goodProperties?.ForEach(s => s.goodId = 0);
            }
            if (model.goodProperties == null || model.goodProperties.Count == 0)
            {
                model.goodProperties = new List <GoodProperty> {
                    new GoodProperty()
                }
            }
            ;                                                                         //чтобы была хотя бы одна пустая стркоа для заполнения
            return(PartialView(model));
        }
 public ActionResult Details(long goodId)
 {
     try
     {
         var store = new StoreAction();
         var good  = store.GetGoodInfo(goodId);
         var model = new GoodDetailsViewModel(good);
         model.feedbacks       = store.GetFeedBack(goodId);
         model.canSendFeedback = Session.IsAuth() && !model.feedbacks.Any(s => s.userId == Session.GetUserId());
         if (Session.IsAuth())
         {
             var customer = new CustomerAction(Session.GetUserId());
             customer.SetThatWatching(goodId);
         }
         SetPratentGroupLinks(good.groupId);
         (ViewBag.Links as Queue <Link>).Enqueue(new Link {
             description = good.name, url = $"~/Details/{good.groupId}/{good.id}"
         });
         return(View(model));
     }
     catch (Exception ex)
     {
         HttpContext.Response.Redirect("/Error/_404", true);
         return(null);
     }
 }
        public void GetGoodInfo()
        {
            var  storeAction = new StoreAction();
            var  rand        = new Random();
            Good fullGood    = null;
            var  goods       = storeAction.GetAllGoods();

            for (int i = 0; i < 10; i++)
            {
                var randomGood = goods.ElementAt(rand.Next(goods.Count()));
                fullGood = storeAction.GetGoodInfo(randomGood.id);
            }
            // TODO: Add your test code here
            Assert.IsTrue(fullGood != null);
        }
        public ActionResult _partialCreateEditImageGood(long goodId)
        {
            if (goodId == 0)
            {
                return(Redirect("~/Error/_404"));
            }

            var store = new StoreAction();
            var good  = store.GetGoodInfo(goodId);
            var model = new GoodImageEditorModel
            {
                goodId = goodId,
                name   = good.name,
                images = good.images
            };

            return(PartialView("_partialGoodsImageEditor", model));
        }