public ProductDetailsModel GetProductDetails(int productId, CurrencyTypeName currencyTypeName)
 {
     try
     {
         System.Configuration.AppSettingsReader settingsReader = new AppSettingsReader();
         string host = (string)settingsReader.GetValue("WebHostName", typeof(String));
         using (var productContract = new ProductContract())
         {
             var product = productContract.GetProductDetails(productId, currencyTypeName);
             if (product != null && product.ProductImages != null && product.ProductImages.Count() > 0)
             {
                 product.ProductImages.ForEach(y =>
                 {
                     y.GalleryImageURL = y.GalleryImageURL.Replace("..", host);
                     y.ImageURL        = y.ImageURL.Replace("..", host);
                     y.ThumbImageURL   = y.ThumbImageURL.Replace("..", host);
                 });
             }
             return(product);
         }
     }
     catch
     {
         throw;
     }
 }
Exemple #2
0
        public ApiResponse <bool> AddToWishList(int productId, CurrencyTypeName CurrencyName)
        {
            var deviceNo = GetDeviceNo();
            var isSave   = _productServices.AddToWishList(productId, CurrencyName, deviceNo);

            return(ApiUtility.ApiSuccess <bool>(isSave, isSave ? "Wishlist item added successfully" : "Failed!!!"));
        }
Exemple #3
0
        public ApiResponse <List <ProductSummaryModel> > GetFeaturedProducts(CurrencyTypeName currencyName)
        {
            var deviceNo = GetDeviceNo();
            var products = _productServices.GetFeaturedProducts(currencyName, deviceNo);

            return(ApiUtility.ApiSuccess <List <ProductSummaryModel> >(products, "Featured products listing successfully"));
        }
 public List <ProductSummaryModel> GetFeaturedProducts(CurrencyTypeName currencyTypeName, string deviceNo)
 {
     try
     {
         System.Configuration.AppSettingsReader settingsReader = new AppSettingsReader();
         string host   = (string)settingsReader.GetValue("WebHostName", typeof(String));
         var    search = new SearchProductModel
         {
             CurrencyName = currencyTypeName,
         };
         using (var productContract = new ProductContract())
         {
             var products = productContract.GetProducts(search, deviceNo, true);
             products.ForEach(x =>
             {
                 x.ProductImages.ForEach(y =>
                 {
                     y.GalleryImageURL = y.GalleryImageURL.Replace("..", host);
                     y.ImageURL        = y.ImageURL.Replace("..", host);
                     y.ThumbImageURL   = y.ThumbImageURL.Replace("..", host);
                 });
             });
             return(products);
         }
     }
     catch
     {
         throw;
     }
 }
Exemple #5
0
        public List <ProductSummaryModel> GetProducts(SearchProductModel search, string deviceNo, bool isFeaturedProducts)
        {
            try
            {
                CurrencyTypeName currencyTypeName = search.CurrencyName;
                using (var dataContext = new BrownBagDataEntities())
                {
                    var isExclusiveUser = CheckExclusiveUser(dataContext, deviceNo.Trim());
                    var ratings         = dataContext.Ratings.GroupBy(g => g.ProductID).Select(s2 => new { ProductId = s2.Key, Average = s2.Average(p => p.Rating1 ?? 0), ReviewCount = s2.Where(w => string.IsNullOrEmpty(w.Review)).Count() }).ToList();
                    var products        = dataContext.Products
                                          .Where(w => (isFeaturedProducts == false || w.IsRental == (isFeaturedProducts == true ? 1 : 0)) &&
                                                 w.Published == 1 &&
                                                 (isExclusiveUser == true || w.IsExclusive == (isExclusiveUser == true ? 1 : 0)) &&
                                                 (search.CategoryIds.Count == 0 || (search.CategoryIds.Any(k => k == (w.CategoryID ?? 0)))) &&
                                                 (search.BrandIds.Count == 0 || (search.BrandIds.Any(k => k == (w.ManufacturerID ?? 0)))) &&
                                                 (search.ArtistIds.Count == 0 || (search.ArtistIds.Any(k => k == (w.ArtistID ?? 0)))) &&
                                                 (search.VendorIds.Count == 0 || (search.VendorIds.Any(k => k == (w.VendorID ?? 0)))) &&
                                                 (search.ProductSearchText == null || search.ProductSearchText == "" || w.FullDescription.Contains(search.ProductSearchText) || w.ShortDescription.Contains(search.ProductSearchText) || w.ProductName.Contains(search.ProductSearchText))
                                                 ).AsEnumerable()
                                          .Select(s => new ProductSummaryModel
                    {
                        Id               = s.Id,
                        CategoryId       = s.CategoryID ?? 0,
                        ManufacturerId   = s.ManufacturerID ?? 0,
                        ArtistId         = s.ArtistID ?? 0,
                        VendorId         = s.VendorID ?? 0,
                        CurrencyType     = currencyTypeName.ToString(),
                        FullDescription  = s.FullDescription ?? "",
                        ProductName      = s.ProductName ?? "",
                        ShortDescription = s.ShortDescription ?? "",
                        Discount         = s.Discount ?? 0,
                        Stock            = s.Stock ?? 0,
                        IsExclusive      = (s.IsExclusive ?? 0) == 1 ? true : false,
                        Price            = (currencyTypeName == CurrencyTypeName.INR) ? s.CP_INR ?? 0 : (currencyTypeName == CurrencyTypeName.USD) ? s.CP_USD ?? 0 : (currencyTypeName == CurrencyTypeName.EURO) ? s.CP_Euro ?? 0 : s.CP_GBP ?? 0,
                        ProductImages    = dataContext.ProductImages.Where(x => x.ProductID == s.Id).Select(s1 => new Model.ProductImage
                        {
                            Id = s1.Id,
                            GalleryImageURL = s1.GalleryImageURL,
                            ImageURL        = s1.ImageURL,
                            ThumbImageURL   = s1.ThumbImageURL,
                            Sequences       = s1.Sequences ?? 0
                        }).OrderBy(o => o.Sequences).ToList(),

                        Rating      = ratings.Where(w1 => w1.ProductId == s.Id).Count() > 0 ? ratings.Where(w1 => w1.ProductId == s.Id).FirstOrDefault().Average : 0,
                        ReviewCount = ratings.Where(w1 => w1.ProductId == s.Id).Count() > 0 ? ratings.Where(w1 => w1.ProductId == s.Id).FirstOrDefault().ReviewCount : 0,
                    })
                                          .ToList();
                    return(products);
                }
            }
            catch
            {
                throw;
            }
        }
Exemple #6
0
        public ApiResponse <bool> AddToCart(int productId, CurrencyTypeName CurrencyName)
        {
            var deviceNo = GetDeviceNo();
            var isSave   = _productServices.AddToCart(productId, CurrencyName, deviceNo);

            if (isSave == true)
            {
                return(ApiUtility.ApiSuccess <bool>(isSave, "Item added to cart"));
            }
            return(ApiUtility.ApiSuccess <bool>(isSave, "Failed !!!"));
        }
Exemple #7
0
 public bool AddToCart(int productId, CurrencyTypeName currencyTypeName, string deviceNumber)
 {
     try
     {
         using (var dataContext = new BrownBagDataEntities())
         {
             var userInfo = dataContext.DeviceRegistrations.Where(a => a.IMEI_Number == deviceNumber).FirstOrDefault();
             if (userInfo != null && userInfo.RefCustomerGuid != null)
             {
                 var product = dataContext.Products.Where(a => a.Id == productId).FirstOrDefault();
                 if (product != null)
                 {
                     if (product.Stock > 0)
                     {
                         var itemPrice             = (currencyTypeName == CurrencyTypeName.INR) ? product.CP_INR ?? 0 : (currencyTypeName == CurrencyTypeName.USD) ? product.CP_USD ?? 0 : (currencyTypeName == CurrencyTypeName.EURO) ? product.CP_Euro ?? 0 : product.CP_GBP ?? 0;
                         ShoppingCartItem cartItem = new ShoppingCartItem
                         {
                             CreatedOnUtc = DateTime.Now.ToUniversalTime(),
                             UpdatedOnUtc = DateTime.Now.ToUniversalTime(),
                             Currency     = currencyTypeName.ToString(),
                             Customer_Id  = userInfo.RefCustomerGuid.Value,
                             ProductId    = productId,
                             ProductPrice = itemPrice,
                             Quantity     = 1,
                             RevisedPrice = 0
                         };
                         dataContext.ShoppingCartItems.Add(cartItem);
                         return(dataContext.SaveChanges() > 0 ? true : false);
                     }
                     else
                     {
                         return(false);
                     }
                 }
                 else
                 {
                     return(false);
                 }
             }
             else
             {
                 return(false);
             }
         }
     }
     catch
     {
         throw;
     }
 }
 public bool AddToCart(int productId, CurrencyTypeName currencyTypeName, string deviceNumber)
 {
     try
     {
         using (var productContract = new ProductContract())
         {
             var product = productContract.AddToCart(productId, currencyTypeName, deviceNumber);
             return(product);
         }
     }
     catch
     {
         throw;
     }
 }
Exemple #9
0
        public ApiResponse <ProductDetailsModel> GetProductdetails(int productId, CurrencyTypeName CurrencyName)
        {
            var product = _productServices.GetProductDetails(productId, CurrencyName);

            return(ApiUtility.ApiSuccess <ProductDetailsModel>(product, "Product details get successfully"));
        }
Exemple #10
0
        public ProductDetailsModel GetProductDetails(int productId, CurrencyTypeName currencyTypeName)
        {
            try
            {
                using (var dataContext = new BrownBagDataEntities())
                {
                    var ratings = dataContext.Ratings.Where(a => a.ProductID == productId && a.ReviewStatus == 1).ToList();
                    ratings.ForEach(a =>
                    {
                        if (a.CustomerName.Trim() == "Gaust")
                        {
                            a.CustomerName = "";
                        }
                    });
                    var productInfo = dataContext.ProductAttributes.Where(a => a.ProductID == productId).ToList();

                    var products = dataContext.Products
                                   .Where(w => w.Id == productId).AsEnumerable()
                                   .Select(s => new ProductDetailsModel
                    {
                        Id               = s.Id,
                        CategoryId       = s.CategoryID ?? 0,
                        ManufacturerId   = s.ManufacturerID ?? 0,
                        ArtistId         = s.ArtistID ?? 0,
                        VendorId         = s.VendorID ?? 0,
                        CurrencyType     = currencyTypeName.ToString(),
                        FullDescription  = s.FullDescription ?? "",
                        ProductName      = s.ProductName ?? "",
                        ShortDescription = s.ShortDescription ?? "",
                        Discount         = s.Discount ?? 0,
                        Stock            = s.Stock ?? 0,
                        Price            = (currencyTypeName == CurrencyTypeName.INR) ? s.CP_INR ?? 0 : (currencyTypeName == CurrencyTypeName.USD) ? s.CP_USD ?? 0 : (currencyTypeName == CurrencyTypeName.EURO) ? s.CP_Euro ?? 0 : s.CP_GBP ?? 0,
                        ProductImages    = dataContext.ProductImages.Where(x => x.ProductID == s.Id).Select(s1 => new Model.ProductImage
                        {
                            Id = s1.Id,
                            GalleryImageURL = s1.GalleryImageURL,
                            ImageURL        = s1.ImageURL,
                            ThumbImageURL   = s1.ThumbImageURL,
                            Sequences       = s1.Sequences ?? 0
                        }).OrderBy(o => o.Sequences).ToList(),

                        Rating      = (ratings != null && ratings.Count() > 0) ? ratings.Select(s2 => s2.Rating1 ?? 0).Average() : 0,
                        ReviewCount = (ratings != null && ratings.Count() > 0) ? ratings.Where(s3 => s3.CustomerName != "").Count() : 0,
                        Reviewes    = (ratings != null && ratings.Count() > 0) ? ratings.Where(s3 => s3.CustomerName != "").Select(s3 => new ProductRatingModel
                        {
                            CustomerName = s3.CustomerName ?? "",
                            DislikeCount = s3.DislikeCount ?? 0,
                            Id           = s3.Id,
                            LikeCount    = s3.LikeCount ?? 0,
                            ProductID    = s3.ProductID ?? 0,
                            Rating       = s3.Rating1 ?? 0,
                            ReviewText   = s3.Review ?? "",
                            ReviewTitle  = s3.ReviewTitle ?? ""
                        }).ToList() : new List <ProductRatingModel>(),
                        BrandName          = dataContext.Manufacturers.Where(s4 => s4.Id == (s.ManufacturerID ?? 0)).Select(s4 => s4.ManufacturerName).FirstOrDefault() ?? "",
                        ArtistName         = dataContext.Artists.Where(s4 => s4.Id == (s.ArtistID ?? 0)).Select(s4 => s4.Artists).FirstOrDefault() ?? "",
                        VendorName         = dataContext.Vendors.Where(s4 => s4.Id == (s.VendorID ?? 0)).Select(s4 => s4.VendorName).FirstOrDefault() ?? "",
                        CategoryName       = dataContext.Categories.Where(s4 => s4.Id == (s.CategoryID ?? 0)).Select(s4 => s4.Name).FirstOrDefault() ?? "",
                        ProductInformation = (productInfo != null && productInfo.Count() > 0) ? productInfo.Select(s4 => s4.ProductInformation).FirstOrDefault() ?? "" : "",
                        ShippingReturns    = "We deliver to over 100 countries around the world. For full details of the delivery options we offer, please view our Delivery information We hope you’ll love every purchase,but if you ever need to return an item you can do so within a month of receipt.For full details of how to make a return, please view our Returns information",
                        SocialMedias       = dataContext.SocialMedias.Select(s4 => new SocialMediaModel
                        {
                            Facebook  = s4.Facebook ?? "",
                            Instagram = s4.Instagram ?? "",
                            Twitter   = s4.Twitter ?? "",
                            Youtube   = s4.Youtube ?? ""
                        }).ToList()
                    })
                                   .ToList();
                    return(products.FirstOrDefault());
                }
            }
            catch
            {
                throw;
            }
        }