public ActionResult ProductList()
        {
            List <ViewProductList> productList = new List <ViewProductList>();

            foreach (Product item in productRepo.GetAll())
            {
                Seller          seller   = sellerRepo.Get(item.SellerId);
                ViewProductList listItem = new ViewProductList();
                listItem.Id         = item.ProductId;
                listItem.Name       = item.Name;
                listItem.Price      = item.Price;
                listItem.Catagory   = catagoryRepo.Get(item.CatagoryId).Name;
                listItem.SellerName = seller.FirstName;
                listItem.ShopName   = sellerAddressRepo.Get(seller.AddressId).ShopName;

                productList.Add(listItem);
            }

            return(View(productList));
        }
示例#2
0
        public List <Models.Watch> GetSellerWatches(int sellerId, int?pageNumber, int?pageSize, out int count)
        {
            Seller seller = sellerRepository.Get().Where(s => s.Id == sellerId).Include(s => s.User.Watches).FirstOrDefault();

            if (seller == null)
            {
                throw new NotFoundException("فروشنده");
            }

            IQueryable <Models.Watch> result = seller.User.Watches.OrderByDescending(w => w.DateCreated).AsQueryable();

            count = result.Count();

            if (pageNumber.HasValue && pageSize.HasValue)
            {
                result = result.Skip((pageNumber.Value - 1) * pageSize.Value).Take(pageSize.Value);
            }
            else
            {
                result = result.Take(10);
            }

            return(result.ToList());
        }
        public ActionResult Add(ViewProduct vProduct)
        {
            if (ModelState.IsValid)
            {
                int     id      = (int)Session["SID"];
                Product product = new Product();
                product.Name     = vProduct.Name;
                product.Price    = vProduct.Price;
                product.SellerId = sellerRepo.Get(id).SellerId;
                product.Catagory = catagoryRepo.Get(vProduct.CatagoryId);
                product.Approval = new ProductApproval();
                productRepo.Insert(product);

                return(RedirectToAction("Index", "Seller", new { @id = id }));
            }

            else
            {
                return(View(vProduct));
            }
        }
示例#4
0
 public Seller Id(int id)
 {
     return(_repository.Get(id));
 }
示例#5
0
        public ActionResult <Seller> GetSeller(string name)
        {
            var repo = new SellerRepository();

            return(repo.Get(name));
        }