Ejemplo n.º 1
0
        public static ProductionSpecification RemoveReferences(this ProductionSpecification item)
        {
            var obj = new ProductionSpecification();

            obj = item.RemoveReference();
            if (item.Product != null)
            {
                obj.Product = new Product();
                obj.Product = item.Product.RemoveReference();
            }
            return(obj);
        }
Ejemplo n.º 2
0
        public static ProductionSpecification RemoveReference(this ProductionSpecification item)
        {
            var obj = new ProductionSpecification();

            if (item != null)
            {
                obj.Id          = item.Id;
                obj.HeadingName = item.HeadingName;
                obj.Description = item.Description;
                obj.ProductId   = item.ProductId;
                obj.Product     = item.Product;
                obj.IsActive    = item.IsActive;
            }
            return(obj);
        }
Ejemplo n.º 3
0
        public override IDeepCopyable CopyTo(IDeepCopyable other)
        {
            var dest = other as DeviceComponent;

            if (dest != null)
            {
                base.CopyTo(dest);
                if (Type != null)
                {
                    dest.Type = (Hl7.Fhir.Model.CodeableConcept)Type.DeepCopy();
                }
                if (Identifier != null)
                {
                    dest.Identifier = (Hl7.Fhir.Model.Identifier)Identifier.DeepCopy();
                }
                if (LastSystemChangeElement != null)
                {
                    dest.LastSystemChangeElement = (Hl7.Fhir.Model.Instant)LastSystemChangeElement.DeepCopy();
                }
                if (Source != null)
                {
                    dest.Source = (Hl7.Fhir.Model.ResourceReference)Source.DeepCopy();
                }
                if (Parent != null)
                {
                    dest.Parent = (Hl7.Fhir.Model.ResourceReference)Parent.DeepCopy();
                }
                if (OperationalStatus != null)
                {
                    dest.OperationalStatus = new List <Hl7.Fhir.Model.CodeableConcept>(OperationalStatus.DeepCopy());
                }
                if (ParameterGroup != null)
                {
                    dest.ParameterGroup = (Hl7.Fhir.Model.CodeableConcept)ParameterGroup.DeepCopy();
                }
                if (MeasurementPrincipleElement != null)
                {
                    dest.MeasurementPrincipleElement = (Code <Hl7.Fhir.Model.DeviceComponent.Measmnt_Principle>)MeasurementPrincipleElement.DeepCopy();
                }
                if (ProductionSpecification != null)
                {
                    dest.ProductionSpecification = new List <Hl7.Fhir.Model.DeviceComponent.ProductionSpecificationComponent>(ProductionSpecification.DeepCopy());
                }
                if (LanguageCode != null)
                {
                    dest.LanguageCode = (Hl7.Fhir.Model.CodeableConcept)LanguageCode.DeepCopy();
                }
                return(dest);
            }
            else
            {
                throw new ArgumentException("Can only copy to an object of the same type", "other");
            }
        }
Ejemplo n.º 4
0
        public IActionResult CompareProducts(int?UserId, string IpAddress)
        {
            var productDetail     = new product1();
            var productDetaillist = new List <product1>();
            var obj            = new List <CompareProduct>();
            var productDetails = new ProductionSpecification();

            try
            {
                if (UserId > 0)
                {
                    obj = db.CompareProducts.Where(x => x.IsActive == true && x.UserId == UserId)
                          .Include(X => X.ProductVariantDetail)
                          .Include(X => X.ProductVariantDetail.Product)
                          .Include(X => X.ProductVariantDetail.Product.ProductImages)
                          .Include(x => x.ProductVariantDetail.Product.RatingReviews)
                          .Include(x => x.ProductVariantDetail.Product.ProductionSpecifications)
                          .Take(4)
                          .ToList();
                }
                else if (IpAddress != null)
                {
                    obj = db.CompareProducts.Where(x => x.IsActive == true && x.IpAddress == IpAddress)
                          .Include(X => X.ProductVariantDetail)
                          .Include(X => X.ProductVariantDetail.Product)
                          .Include(X => X.ProductVariantDetail.Product.ProductImages)
                          .Include(x => x.ProductVariantDetail.Product.RatingReviews)
                          .Include(x => x.ProductVariantDetail.Product.ProductionSpecifications)
                          .Take(4)
                          .ToList();
                }
                foreach (var item in obj)
                {
                    productDetail = new product1();
                    // productDetail.ProductSpecificationDescription = item.ProductVariantDetail.Product.ProductionSpecifications.Select(x => x.Description).FirstOrDefault();
                    // productDetail.ProductSpecificationHeading = item.ProductVariantDetail.Product.ProductionSpecifications.Select(x => x.HeadingName).FirstOrDefault();
                    foreach (var spec in item.ProductVariantDetail.Product.ProductionSpecifications)
                    {
                        productDetails             = new ProductionSpecification();
                        productDetails.HeadingName = item.ProductVariantDetail.Product.ProductionSpecifications.Select(x => x.Description).FirstOrDefault();
                        productDetails.Description = item.ProductVariantDetail.Product.ProductionSpecifications.Select(x => x.HeadingName).FirstOrDefault();
                    }

                    productDetail.ProductionSpecification.Add(productDetails);
                    productDetail.ProductId          = item.ProductVariantDetail.ProductId;
                    productDetail.VariantDetailId    = item.ProductVariantDetailId;
                    productDetail.CompareProductId   = item.Id;
                    productDetail.Name               = item.ProductVariantDetail.Product.Name;
                    productDetail.ShipmentVendor     = item.ProductVariantDetail.Product.ShipmentVendor ?? false;
                    productDetail.ShipmentTime       = item.ProductVariantDetail.Product.ShipmentTime ?? 0;
                    productDetail.ShipmentCost       = item.ProductVariantDetail.Product.ShipmentCost ?? 0;
                    productDetail.Description        = item.ProductVariantDetail.Product.Description.Length >= 255? item.ProductVariantDetail.Product.Description.Substring(0, 255): item.ProductVariantDetail.Product.Description;
                    productDetail.SellingPrice       = item.ProductVariantDetail.Price;
                    productDetail.Discount           = item.ProductVariantDetail.Discount;
                    productDetail.PriceAfterdiscount = item.ProductVariantDetail.PriceAfterdiscount;
                    productDetail.InStock            = item.ProductVariantDetail.InStock;
                    if (item.ProductVariantDetail.Product.ProductImages.Count > 0)
                    {
                        if (item.ProductVariantDetail.Product.ProductImages.Any(c => c.IsDefault == true))
                        {
                            productDetail.LandingImage150 = item.ProductVariantDetail.Product.ProductImages.Where(c => c.IsDefault == true && c.IsActive == true).FirstOrDefault().ImagePath150x150;
                        }
                        else
                        {
                            productDetail.LandingImage150 = item.ProductVariantDetail.Product.ProductImages.Where(c => c.IsActive == true).FirstOrDefault().ImagePath150x150;
                        }
                    }
                    var reviewCount = item.ProductVariantDetail.Product.RatingReviews.Where(X => X.Review != null).Count();
                    var ratingCount = item.ProductVariantDetail.Product.RatingReviews.Where(x => x.Rating > 0).Count();
                    var ratingSum   = item.ProductVariantDetail.Product.RatingReviews.Where(x => x.Rating > 0).Sum(x => x.Rating);

                    productDetail.ReviewCount = reviewCount;
                    if (ratingCount > 0 && ratingSum > 0)
                    {
                        var ratingAvg = Convert.ToSingle(ratingSum) / Convert.ToSingle(ratingCount);
                        productDetail.RatingAvg = ratingAvg;
                    }
                    if (productDetail.ReviewCount > 0 && productDetail.RatingAvg > 0)
                    {
                        productDetail.ReviewCount = 0;
                        productDetail.RatingAvg   = 0;
                    }
                    if (productDetail.LandingVariant == null)
                    {
                        productDetail.LandingVariant = new ProductVariantDetailModel();
                    }

                    productDetail.LandingVariant.Id = Convert.ToInt32(productDetail.VariantDetailId);
                    productDetaillist.Add(productDetail);
                }
                productDetaillist = DealHelper.calculateDealForProductsList(productDetaillist, db);
                productDetaillist = PriceIncrementHelper.calculatePriceForProductsList(productDetaillist, db);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.InnerException);
            }
            return(Ok(productDetaillist));
        }