Ejemplo n.º 1
0
        public IActionResult FilterProdReviews(int ProductId)
        {
            var product2List = new List <product2>();

            try
            {
                if (ProductId > 0)
                {
                    var UserData = db.RatingReviews.Where(x => x.ProductId == ProductId).ToList();
                    foreach (var item in UserData)
                    {
                        var product2 = new product2();
                        product2 = allProducts(item.ProductId);
                        product2List.Add(product2);
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return(Ok(product2List));
        }
Ejemplo n.º 2
0
        public IActionResult FilterProdReviews(string firstDate, string lastDate, int ProductId, int ReviewSatusId)
        {
            var product2List = new List <product2>();

            try
            {
                if (firstDate != null && lastDate != null)
                {
                    var first    = Convert.ToDateTime(firstDate);
                    var Seconed  = Convert.ToDateTime(lastDate);
                    var data     = db.RatingReviews.Where(x => x.ReviewDate.Date >= first.Date && x.ReviewDate.Date <= Seconed.Date).ToList();
                    var UserData = data.Where(x => x.ProductId == ProductId).ToList();
                    foreach (var item in UserData)
                    {
                        var product2 = new product2();
                        product2 = allProducts(item.ProductId);
                        product2List.Add(product2);
                    }
                }
                else if (ReviewSatusId > 0)
                {
                    var data     = db.RatingReviews.Where(x => x.ReviewStatusId == ReviewSatusId).ToList();
                    var UserData = data.Where(x => x.ProductId == ProductId).ToList();
                    foreach (var item in UserData)
                    {
                        var product2 = new product2();
                        product2 = allProducts(item.ProductId);
                        product2List.Add(product2);
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return(Ok(product2List));
        }
Ejemplo n.º 3
0
        public IActionResult reviewsofproduct(int productId, int ReviewSatusId)
        {
            var product2List = new List <product2>();

            try
            {
                if (ReviewSatusId > 0 && productId > 0)
                {
                    var data     = db.RatingReviews.Where(x => x.ReviewStatusId == ReviewSatusId).ToList();
                    var UserData = data.Where(x => x.ProductId == productId).ToList();
                    foreach (var item in UserData)
                    {
                        var product2 = new product2();
                        product2 = allProducts(item.ProductId);
                        product2List.Add(product2);
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return(Ok(product2List));
        }
Ejemplo n.º 4
0
        public product2 allProducts(int Id)
        {
            var eachPrd = new product2();

            try
            {
                var data = db.Products.Where(x => x.IsActive == true && x.Id == Id)
                           .Include(c => c.ProductVariantDetails)
                           .Include(x => x.RatingReviews)
                           .Include(x => x.ProductImages).FirstOrDefault();
                eachPrd.Id = data.Id;
                var UserId = data.RatingReviews.Select(x => x.UserId).FirstOrDefault();
                eachPrd.UserName   = db.Users.Where(x => x.Id == UserId).FirstOrDefault().FirstName;
                eachPrd.Review     = data.RatingReviews.Select(x => x.Review).FirstOrDefault();
                eachPrd.ReviewDate = data.RatingReviews.Select(x => x.ReviewDate.Date).FirstOrDefault().ToShortDateString();
                var ReviewStatus = data.RatingReviews.Select(x => x.ReviewStatusId).FirstOrDefault();
                if (ReviewStatus == 1)
                {
                    eachPrd.Status = "Approved";
                }
                else if (ReviewStatus == 2)
                {
                    eachPrd.Status = "Pending";
                }
                else if (ReviewStatus == 3)
                {
                    eachPrd.Status = "Not approved";
                }
                if (data.ProductImages.Count() != 0)
                {
                    eachPrd.Url = data.ProductImages?.FirstOrDefault().ImagePath;
                }
                eachPrd.Description       = data.Description;
                eachPrd.Name              = data.Name;
                eachPrd.ProductCategoryId = data.ProductCategoryId;
                if (data.ProductVariantDetails.Where(c => c.IsActive == true).Any(c => c.IsDefault == true))
                {
                    eachPrd.LandingVariant = data.ProductVariantDetails.Where(c => c.IsActive == true).Where(c => c.IsDefault == true && c.IsActive == true).Select(d => new ProductVariantDetailModel
                    {
                        Id                 = d.Id,
                        Price              = d.Price,
                        Discount           = d.Discount,
                        PriceAfterdiscount = d.PriceAfterdiscount,
                        InStock            = d.InStock,
                    }).FirstOrDefault();
                }
                else
                {
                    eachPrd.LandingVariant = data.ProductVariantDetails.Where(c => c.IsActive == true).Select(d => new ProductVariantDetailModel
                    {
                        Id                 = d.Id,
                        Price              = d.Price,
                        Discount           = d.Discount,
                        PriceAfterdiscount = d.PriceAfterdiscount,
                        InStock            = d.InStock,
                    }).FirstOrDefault();
                }
                if (eachPrd.LandingVariant != null)
                {
                    eachPrd.SellingPrice       = eachPrd.LandingVariant.Price;
                    eachPrd.Discount           = eachPrd.LandingVariant.Discount;
                    eachPrd.PriceAfterdiscount = eachPrd.LandingVariant.PriceAfterdiscount;
                    eachPrd.InStock            = eachPrd.LandingVariant.InStock;

                    var img = data.ProductImages.Where(c => c.ProductId == eachPrd.Id && c.ProductVariantDetailId == eachPrd.LandingVariant.Id && c.IsActive == true).ToList();
                    if (img.Any(c => c.IsDefault == true))
                    {
                        eachPrd.Url = img.Where(c => c.IsDefault == true).FirstOrDefault().ImagePath;
                    }
                    else
                    {
                        eachPrd.Url = img.FirstOrDefault().ImagePath;
                    }
                }
                //if (_prd.Count < 12)
                //    _prd.Add(eachPrd);
                //else
                //    break;
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }
            return(eachPrd);
        }