예제 #1
0
        public ActionResult Add()
        {
            VMMakeAdd vmMake      = new VMMakeAdd();
            Guid      teknolojiID = Guid.Parse("35391ff3-c30d-4a6a-b30b-14079eaaa455");

            vmMake.Categories = CategoryDAL.GetList(x => x.SubCategoryID == teknolojiID && x.IsActive == true);
            return(View(vmMake));
        }
예제 #2
0
        public IActionResult GetAll()
        {
            IList <Category> list = _CategoryDal.GetList();

            if (list != null && list.Count > 0)
            {
                return(Ok(list));
            }
            else
            {
                return(NotFound("Burada hiç kayıt bulunmadı!"));
            }
        }
예제 #3
0
        public ActionResult Add()
        {
            Property property = new Property();
            Guid     temp     = Guid.Parse("35391ff3-c30d-4a6a-b30b-14079eaaa455");

            property.Categories = CategoryDAL.GetList(x => x.SubCategoryID == temp);
            return(View());
        }
예제 #4
0
        public ActionResult Add()
        {
            VMProduct p = new VMProduct();
            //p.ProductModels = ProductModelDAL.GetList();
            Guid teknolojiID = Guid.Parse("35391ff3-c30d-4a6a-b30b-14079eaaa455");

            p.Categories = CategoryDAL.GetList(x => x.SubCategoryID == teknolojiID);
            return(View(p));
        }
예제 #5
0
        public DeliveryInfo calculateFor(CartProducts carts)
        {
            List <Carts>        cartItems        = new List <Carts>();
            List <Products>     productItems     = new List <Products>();
            List <Categories>   categoryItems    = new List <Categories>();
            List <CartProducts> cartProductItems = new List <CartProducts>();


            double costForDelivery        = 5.99; //anlaşmalı kargo teslimatı birim fiyatı
            double fixedCost              = 2.99; // sabit fiyat
            double calculatedDeliveryCost = 0.0;

            cartProductItems = _cartProductDAL.GetList();
            cartItems        = _cartDAL.GetList();
            productItems     = _productDAL.GetList();
            categoryItems    = _categoryDAL.GetList();

            var itemsInCart = //sepetteki ürünler ve kategorileri
                              from CartProduct in cartProductItems
                              join Cart in cartItems on CartProduct.CartId equals Cart.Id
                              join Product in productItems on CartProduct.ProductId equals Product.Id


                              select new { Cart.Id, CartProduct.ProductId, Product.CategoryId, Product.Price };

            var thisCartItem = itemsInCart.Where(x => x.Id == carts.CartId).ToList();                                                            // bu sepetteki ürünlerin

            var numberOfProduct  = itemsInCart.Where(x => x.Id == carts.CartId).ToList().Distinct().Select(p => p.ProductId).Count();            // sepette kaç farklı ürün var
            var numberOfDelivery = itemsInCart.Where(x => x.ProductId == carts.ProductId).ToList().Distinct().Select(c => c.CategoryId).Count(); // sepette kaç farklı ürün kategorisi var


            for (int i = 0; i < numberOfProduct; i++)
            {
                var costPerProduct = itemsInCart.Where(x => x.ProductId == carts.ProductId).ToList().Distinct().Select(p => p.Price).FirstOrDefault(); // sepetteki her bir ürünün birim fiyatı
                calculatedDeliveryCost = (costForDelivery * numberOfDelivery) + (Convert.ToDouble(costPerProduct) * numberOfProduct) + fixedCost;      // teslimat tutarının hesaplanması

                Deliveries delivery = new Deliveries()
                {
                    CartId          = itemsInCart.Select(c => c.Id).FirstOrDefault(),
                    CostPerDelivery = costForDelivery,
                    CostPerProduct  = Convert.ToDouble(costPerProduct),
                    FixedCost       = fixedCost
                };

                _deliveryDAL.Add(delivery); // teslimatın eklenmesi
            }
            DeliveryInfo deliveryInfo = new DeliveryInfo()
            {
                Info  = "Kargo Teslimat Tutarı",
                Price = calculatedDeliveryCost
            };

            return(deliveryInfo);
        }
예제 #6
0
 public IDataResult <List <Category> > GetList()
 {
     //Business codes
     return(new SuccessDataResult <List <Category> >(_categoryDal.GetList().ToList()));
 }
예제 #7
0
        public ViewCartItem applyDiscounts(List <Campaigns> campaigns)
        {
            List <Carts>        cartItems        = new List <Carts>();
            List <Products>     productItems     = new List <Products>();
            List <Categories>   categoryItems    = new List <Categories>();
            List <CartProducts> cartProductItems = new List <CartProducts>();


            ViewCartItem viewCartItem = new ViewCartItem();

            cartProductItems = _cartProductDAL.GetList();
            cartItems        = _cartDAL.GetList();
            categoryItems    = _categoryDAL.GetList();
            productItems     = _productDAL.GetList();
            // discountTypeItems = _discountType.GetList();

            var totalPriceInCart = //sepetteki toplam tutar
                                   from CartProduct in cartProductItems
                                   join Cart in cartItems on CartProduct.CartId equals Cart.Id
                                   join Product in productItems on CartProduct.ProductId equals Product.Id

                                   select new { TotalPrice = Cart.TotalPrice, Product.CategoryId, ProductName = Product.Title, UnitPrice = Product.Price, Amount = Cart.Amount };

            var totalAmountInCart = //sepetteki toplam adet
                                    from CartProduct in cartProductItems
                                    join Cart in cartItems on CartProduct.CartId equals Cart.Id
                                    join Product in productItems on CartProduct.ProductId equals Product.Id

                                    select new { TotalAmount = Cart.Amount, Product.CategoryId, ProductId = Product.Id, ProductName = Product.Title, CartId = Cart.Id, UnitPrice = Product.Price, Amount = Cart.Amount };

            // tanımlanacak kampanyalar içinden sepetteki ürünlerde geçerliliğinin kontrolü
            foreach (var campaignCategory in campaigns)
            {
                //kampanyalı kategorinin toplam tutar limiti
                var totalPricebyCampaignCategory = totalPriceInCart.Where(c => c.CategoryId == campaignCategory.CategoryId).Select(p => p.TotalPrice).ToList().FirstOrDefault();


                //kampanyalı kategorinin miktar limiti
                var totalAmountbyCampaignCategory = totalAmountInCart.Where(c => c.CategoryId == campaignCategory.CategoryId).Select(a => a.TotalAmount).ToList().FirstOrDefault();


                //sepette kampanyalı kategori varsa ve kampanya miktar koşulu sağlanıyorsa indirim uygulanacak
                if (totalAmountbyCampaignCategory >= campaignCategory.AmountLimit)
                {
                    int isExist = _campaignDAL.GetList().Where(x => x.Id == campaignCategory.CategoryId).Count();

                    if (isExist < 1)
                    {
                        _campaignDAL.Add(campaignCategory);// kampanya eklendi
                    }

                    var discountedProducts = totalAmountInCart.Where(x => x.CategoryId == campaignCategory.CategoryId);

                    foreach (var item in discountedProducts)
                    {
                        var discountedInCartId = _cartProductDAL.Get(x => x.ProductId == item.ProductId).CartId;
                        var updatedCartItem    = _cartDAL.Get(x => x.Id == discountedInCartId);

                        if (campaignCategory.DiscountTypeId == (int)EnumDiscountTypes.Rate)//Convert.ToInt32(discountTypeItems.Where(a => a.Title == "Rate").Select(x => x.Id).ToList()))
                        {
                            //kampanyanın oran bazında indirimli halinin sepet tutarına yansıtılmış hali
                            var discountedPriceForRate = totalPricebyCampaignCategory - (totalPricebyCampaignCategory * campaignCategory.DiscountRate) / 100;
                            updatedCartItem.TotalPrice = discountedPriceForRate;
                        }
                        else if (campaignCategory.DiscountTypeId == (int)EnumDiscountTypes.Amount) //Convert.ToInt32(discountTypeItems.Where(a => a.Title == "Amount").Select(x => x.Id).ToList()))
                        {
                            //kampanyanın miktar bazında indirimli halinin sepet tutarına yansıtılmış hali
                            var discountedPriceForAmount = totalPricebyCampaignCategory - campaignCategory.DiscountRate;
                            updatedCartItem.TotalPrice = discountedPriceForAmount;
                        }
                        _cartDAL.Update(updatedCartItem);
                        viewCartItem.TotalPriceInCart     = updatedCartItem.TotalPrice;
                        viewCartItem.DiscountedTotalPrice = updatedCartItem.TotalPrice;
                        viewCartItem.Amount      = item.TotalAmount;
                        viewCartItem.CartId      = item.CartId;
                        viewCartItem.ProductName = item.ProductName;
                        viewCartItem.TotalPrice  = item.TotalAmount * item.UnitPrice;
                        viewCartItem.UnitPrice   = totalPriceInCart.FirstOrDefault().UnitPrice;
                    }
                }
                else
                {
                    viewCartItem.TotalPriceInCart = totalPriceInCart.FirstOrDefault().TotalPrice;
                    viewCartItem.ErrorInfo        = "Sepette kampanyalı olan kategorilere ait yeterli veya hiç ürün yok !";
                    //sepette kampanyalı kategoriye ait ürün yok!
                }
            }
            return(viewCartItem);
        }
예제 #8
0
 public List <Category> GetAll()
 {
     return(_categoryDal.GetList());
 }
예제 #9
0
파일: CategoryBLL.cs 프로젝트: uewill/qsnwl
 /// <summary>
 /// 获得数据列表
 /// </summary>
 public DataSet GetList(string strWhere)
 {
     return(dal.GetList(strWhere));
 }
예제 #10
0
 public ActionResult Navbar()
 {
     return(PartialView(categoryDAL.GetList().OrderBy(x => x.CategoryName).ToList()));
 }
예제 #11
0
 public IList <Category> GetAll()
 {
     return(_categoryDAL.GetList());
 }
예제 #12
0
 public List <Categories> getCategories()
 {
     return(_categoryDAL.GetList());
 }