示例#1
0
        //#region Readonly properties

        //public ProductPrice LastProductPrice
        //{
        //    get
        //    {
        //        try
        //        {
        //            return ProductPrices.OrderByDescending(p => p.Date).FirstOrDefault();
        //        }
        //        catch
        //        {

        //        }
        //        return null;
        //    }
        //}

        //public Guid ProductPriceId
        //{
        //    get
        //    {
        //        try
        //        {
        //            if (LastProductPrice != null)
        //            {
        //                return LastProductPrice.Id;
        //            }
        //        }
        //        catch
        //        {

        //        }
        //        return Guid.Empty;
        //    }
        //}

        //public decimal LastPriceWithDiscount
        //{
        //    get
        //    {
        //        try
        //        {
        //            if (LastProductPrice != null)
        //            {
        //                return LastProductPrice.PriceWithDiscount;
        //            }
        //        }
        //        catch
        //        {

        //        }
        //        return 0;
        //    }
        //}

        //public decimal LastPriceWithoutDiscount
        //{
        //    get
        //    {
        //        try
        //        {
        //            if (LastProductPrice != null)
        //            {
        //                return LastProductPrice.PriceWithoutDiscount;
        //            }
        //        }
        //        catch
        //        {

        //        }
        //        return 0;
        //    }
        //}

        //public bool IsAvailable
        //{
        //    get
        //    {
        //        try
        //        {
        //            return ProductAvailabilities.OrderByDescending(p => p.Date).FirstOrDefault().IsAvailable;
        //        }
        //        catch
        //        {

        //        }
        //        return false;
        //    }
        //}

        //public bool HasDiscount
        //{
        //    get
        //    {
        //        return LastPriceWithoutDiscount > LastPriceWithDiscount;
        //    }
        //}

        //public decimal Discount
        //{
        //    get
        //    {
        //        try
        //        {
        //            if (ProductPrices != null)
        //            {
        //                return Math.Round(ProductPrices.OrderByDescending(p => p.Date).FirstOrDefault().Discount);
        //            }
        //        }
        //        catch
        //        {

        //        }

        //        return 0;

        //    }
        //}

        //public decimal DiscountInPercent
        //{
        //    get
        //    {
        //        try
        //        {
        //            if (ProductPrices != null)
        //            {
        //                return Math.Round(ProductPrices.OrderByDescending(p => p.Date).FirstOrDefault().DiscountInPercent);
        //            }
        //        }
        //        catch
        //        {

        //        }

        //        return 0;
        //    }
        //}
        //#endregion

        #region Methods

        public void SetProductSummary()
        {
            if (ProductType != null && ProductPropertyValues != null)
            {
                // these are the property values that they are not included in the userDecision set and so we want to show them in product summary
                List <ProductPropertyValue> properties = ProductPropertyValues.Where(p => p.ProductTypeProperty.IsUserDecision == false).ToList();

                string pSummary;

                // This is an array that keep those not user desicioned properties from the end til the begining because of right to left problems
                string[] strArray = new string[properties.Count + 1];
                int      counter  = properties.Count;

                // at first we add the product type title of the product in the array for example : تی شرت and after that we add product property values
                strArray[counter] = ProductType.Title;

                foreach (ProductPropertyValue pValue in properties)
                {
                    strArray[--counter] = pValue.Value;
                }

                pSummary = "";

                for (int i = strArray.Length - 1; i >= 0; i--)
                {
                    pSummary += strArray[i];
                    pSummary += " ";
                }

                Summary = pSummary;
            }
        }
        public void Delete(int productPropertyValuesId)
        {
            ProductPropertyValues productPropertyValues = GetById(productPropertyValuesId);

            _productPropertyValuesRepository.Delete(productPropertyValues);
            _unitOfWork.Complete();
        }
 public void Update(ProductPropertyValues productPropertyValues)
 {
     _productPropertyValuesRepository.Update(productPropertyValues);
     _unitOfWork.Complete();
 }
 public void Save(ProductPropertyValues productPropertyValues)
 {
     _productPropertyValuesRepository.Add(productPropertyValues);
     _unitOfWork.Complete();
 }