Ejemplo n.º 1
0
        public Boolean PlaceOrder(PlacedOrderModel model)
        {
            var orders = new List <PlacedOrder>();
            var modelK = _kartDA.GetCustomerKart(model.Customer_ID);

            var orderNumber = _placeOrderDA.GetOrderNumber();     //Creating Order number

            if (orderNumber == 0)
            {
                orderNumber = 999;
            }
            orderNumber += 1;

            var    modelA  = _addressDA.GetAddress(model.Address_ID);  //Creating Address
            string address = "Address Line : " + modelA.AddressLine + " City : " + modelA.City + " State : " + modelA.State +
                             " Postal Code : " + modelA.PostalCode + " Address Type : " + modelA.AddressType;

            foreach (var k in modelK)
            {
                if (k.Quantity == 0)
                {
                    continue;
                }

                //common start
                var order = new PlacedOrder();
                order.Customer_ID = model.Customer_ID;
                order.PaymentType = model.PaymentType;

                order.Address  = address;
                order.DateTime = DateTime.Now;
                order.Status   = "Order Placed";

                order.OrderNumber = orderNumber;
                //common finish


                var product = _productDA.GetProduct(k.Product_ID);
                order.Quantity = k.Quantity;
                var ActualPrice = product.ProductPrice - (product.ProductPrice * product.ProductDiscount) / 100;

                order.Amount     = k.Quantity * ActualPrice;
                order.Product_ID = k.Product_ID;
                product.ProductQuantityInKart -= k.Quantity;            //releasing product IN kart value
                product.ProductQuantity       -= k.Quantity;            //Normelizing Quantity
                _kartDA.RemoveKartItem(k.ID, product);                  //remove from kart and updating product IN Kart value
                orders.Add(order);
            }
            if (_placeOrderDA.PlaceOrder(orders))
            {
                return(true);
            }
            return(false);
        }
Ejemplo n.º 2
0
        public Product ProductAvailability(long id, int quantity) //Checking Product Availability
        {
            var productEntity = _productDA.GetProduct(id);        //checking if product exists

            if (productEntity != null)
            {
                var availableQuantity = productEntity.ProductQuantity - productEntity.ProductQuantityInKart;
                if (availableQuantity >= quantity)             //checking if the required quantity is available or not
                {
                    return(productEntity);
                }
            }
            return(null);
        }
Ejemplo n.º 3
0
        public List <ProductModel> GetSuggestedProductsKnownUser(long id) //product Suggession for for know user
        {
            var products = _productDA.TrendingProduct();                  //by trending

            if (products != null)
            {
                AddProductToSuggestionList(products);
            }

            products = _preVisitDA.GetPrevistProducts(id);          //by previst

            if (products != null)
            {
                AddProductToSuggestionList(products);
            }


            var wishlists = _wishlistDA.GetWishlist(id);             //by wishlist

            products = null;
            foreach (var wish in wishlists)
            {
                var product = _productDA.GetProduct(wish.Product_ID);
                products.Add(product);
            }

            if (products != null)
            {
                AddProductToSuggestionList(products);
            }


            return(suggestedProductsList);
        }
Ejemplo n.º 4
0
        public Boolean PutProduct(string value, long id)                                                   //Respond to seller Request :Accepted:Deleted
        {
            if (!(value == "Accepted" || value == "Deleted" || value == "accepted" || value == "deleted")) //check for the "value" if it is valid or not
            {
                return(false);
            }

            var entity = _productDA.GetProduct(id);     //getting the Product by ID

            if (entity != null)
            {
                entity.ProductStatus = value;
                _productDA.UpdateProduct(entity);       //updating the Product with provided value
                return(true);
            }
            return(false);
        }
Ejemplo n.º 5
0
        public List <ProductModel> SimilarProducts(long id)
        {
            var productModelList   = new List <ProductModel>();
            var productByID        = _productDA.GetProduct(id);
            var SimilarProductList = _productDA.GetProductsBYSubCategory(productByID.ProductSubCategory);

            SimilarProductList.Remove(productByID);         //remove product which is already in main page.
            //Above logic will also include the same product.

            foreach (var product in SimilarProductList)
            {
                var model = _mapper.Map <Product, ProductModel>(product);
                model.PicturePath = _productDA.GetSingleProductPicture(product.ID);
                var seller = _sellerDA.GetSellerByID(model.Seller_ID);
                model.SellerName = seller.Name;
                productModelList.Add(model);
            }
            return(productModelList);
        }
Ejemplo n.º 6
0
        public List <ProductModel> Getwishlist(long id)
        {
            var productList = new List <ProductModel>();
            var entity      = _wishlistDA.GetWishlist(id);      // Getting Wishlist Rows

            foreach (var wish in entity)
            {
                var product = _productDA.GetProduct(wish.Product_ID);           //finding product by product ID
                var modelP  = _mapper.Map <Product, ProductModel>(product);     //converting product to productModel
                productList.Add(modelP);
            }
            return(productList);
        }
Ejemplo n.º 7
0
        public List <RecivedOrderModel> OrderRecived(long id)
        {
            var entityList = _placeOrderDA.OrderRecived(id);
            var modelList  = new List <RecivedOrderModel>();

            foreach (var entity in entityList)
            {
                var model   = _mapper.Map <PlacedOrder, RecivedOrderModel>(entity);
                var product = _productDA.GetProduct(entity.Product_ID);
                model.ProductName = product.ProductName;
                model.Product_ID  = product.ID;
                modelList.Add(model);
            }
            return(modelList);
        }
Ejemplo n.º 8
0
        public List <ProductModel> Getwishlist(long id)
        {
            var productList = new List <ProductModel>();
            var entity      = _wishlistDA.GetWishlist(id);      // Getting Wishlist Rows

            foreach (var wish in entity)
            {
                var product = _productDA.GetProduct(wish.Product_ID);       //finding product by product ID
                var modelP  = _mapper.Map <Product, ProductModel>(product); //converting product to productModel
                modelP.Seller_ID = wish.ID;                                 //assign wish id to seller ID(need to change it later)
                var seller = _sellerDA.GetSellerByID(product.Seller_ID);
                modelP.SellerName  = seller.Name;
                modelP.PicturePath = _productDA.GetSingleProductPicture(product.ID);
                productList.Add(modelP);
            }
            return(productList);
        }
Ejemplo n.º 9
0
        public ProductModel GetProduct(long id)         //get product by product ID
        {
            var entity = _mapper.Map <Product, ProductModel>(obj.GetProduct(id));

            return(entity);
        }
Ejemplo n.º 10
0
        // GET: api/Product/5
        public Product Get(int id)
        {
            ClaimsPrincipal p = RequestContext.Principal as ClaimsPrincipal;

            return(ProductDA.GetProduct(id, p.Claims));
        }