public virtual LineItem ToModel(LineItem lineItem) { if (lineItem == null) { throw new ArgumentNullException(nameof(lineItem)); } lineItem.Id = Id; lineItem.CreatedDate = CreatedDate; lineItem.CreatedBy = CreatedBy; lineItem.ModifiedDate = ModifiedDate; lineItem.ModifiedBy = ModifiedBy; lineItem.OuterId = OuterId; lineItem.PriceId = PriceId; lineItem.CatalogId = CatalogId; lineItem.CategoryId = CategoryId; lineItem.Currency = Currency; lineItem.ProductId = ProductId; lineItem.Sku = Sku; lineItem.ProductType = ProductType; lineItem.Name = Name; lineItem.ImageUrl = ImageUrl; lineItem.ShippingMethodCode = ShippingMethodCode; lineItem.FulfillmentLocationCode = FulfillmentLocationCode; lineItem.Price = Price; lineItem.PriceWithTax = PriceWithTax; lineItem.DiscountAmount = DiscountAmount; lineItem.DiscountAmountWithTax = DiscountAmountWithTax; lineItem.Quantity = Quantity; lineItem.TaxTotal = TaxTotal; lineItem.TaxPercentRate = TaxPercentRate; lineItem.Weight = Weight; lineItem.Height = Height; lineItem.Width = Width; lineItem.MeasureUnit = MeasureUnit; lineItem.WeightUnit = WeightUnit; lineItem.Length = Length; lineItem.TaxType = TaxType; lineItem.IsCancelled = IsCancelled; lineItem.CancelledDate = CancelledDate; lineItem.CancelReason = CancelReason; lineItem.Comment = Comment; lineItem.IsGift = IsGift; lineItem.Discounts = Discounts.Select(x => x.ToModel(AbstractTypeFactory <Discount> .TryCreateInstance())).ToList(); lineItem.TaxDetails = TaxDetails.Select(x => x.ToModel(AbstractTypeFactory <TaxDetail> .TryCreateInstance())).ToList(); lineItem.DynamicProperties = DynamicPropertyObjectValues.GroupBy(g => g.PropertyId).Select(x => { var property = AbstractTypeFactory <DynamicObjectProperty> .TryCreateInstance(); property.Id = x.Key; property.Name = x.FirstOrDefault()?.PropertyName; property.Values = x.Select(v => v.ToModel(AbstractTypeFactory <DynamicPropertyObjectValue> .TryCreateInstance())).ToArray(); return(property); }).ToArray(); return(lineItem); }
public DynamicPropertyEntity[] GetObjectDynamicProperties(string objectType, string objectId) { var retVal = DynamicProperties.Where(x => x.ObjectType == objectType) .OrderBy(x => x.Name) .ToArray(); var propertyIds = retVal.Select(x => x.Id).ToArray(); var proprValues = DynamicPropertyObjectValues.Include(x => x.DictionaryItem) .Where(x => propertyIds.Contains(x.PropertyId) && x.ObjectId == objectId).ToArray(); return(retVal); }
public DynamicPropertyEntity[] GetObjectDynamicProperties(string[] objectTypeNames, string[] objectIds) { var properties = DynamicProperties.Include(x => x.DisplayNames) .OrderBy(x => x.Name) .Where(x => objectTypeNames.Contains(x.ObjectType)).ToArray(); var propertyIds = properties.Select(x => x.Id).ToArray(); var proprValues = DynamicPropertyObjectValues.Include(x => x.DictionaryItem.DisplayNames) .Where(x => propertyIds.Contains(x.PropertyId) && objectIds.Contains(x.ObjectId)) .ToArray(); return(properties); }
public virtual void Patch(LineItemEntity target) { if (target == null) { throw new ArgumentNullException(nameof(target)); } target.Quantity = Quantity; target.Weight = Weight; target.Height = Height; target.Width = Width; target.MeasureUnit = MeasureUnit; target.WeightUnit = WeightUnit; target.Length = Length; target.TaxType = TaxType; target.IsCancelled = IsCancelled; target.CancelledDate = CancelledDate; target.CancelReason = CancelReason; target.Comment = Comment; if (!(GetNonCalculatablePrices().All(x => x == 0m) && target.GetNonCalculatablePrices().Any(x => x != 0m))) { target.TaxPercentRate = TaxPercentRate; target.Price = Price; target.DiscountAmount = DiscountAmount; target.PriceWithTax = PriceWithTax; target.DiscountAmountWithTax = DiscountAmountWithTax; target.TaxTotal = TaxTotal; } if (!Discounts.IsNullCollection()) { var discountComparer = AnonymousComparer.Create((DiscountEntity x) => x.PromotionId); Discounts.Patch(target.Discounts, discountComparer, (sourceDiscount, targetDiscount) => sourceDiscount.Patch(targetDiscount)); } if (!TaxDetails.IsNullCollection()) { var taxDetailComparer = AnonymousComparer.Create((TaxDetailEntity x) => x.Name); TaxDetails.Patch(target.TaxDetails, taxDetailComparer, (sourceTaxDetail, targetTaxDetail) => sourceTaxDetail.Patch(targetTaxDetail)); } if (!DynamicPropertyObjectValues.IsNullCollection()) { DynamicPropertyObjectValues.Patch(target.DynamicPropertyObjectValues, (sourceDynamicPropertyObjectValues, targetDynamicPropertyObjectValues) => sourceDynamicPropertyObjectValues.Patch(targetDynamicPropertyObjectValues)); } }
public async Task <QuoteRequestEntity[]> GetQuoteRequestByIdsAsync(params string[] ids) { var result = await QuoteRequests.Where(x => ids.Contains(x.Id)).ToArrayAsync(); ids = result.Select(x => x.Id).ToArray(); if (!ids.IsNullOrEmpty()) { await Addresses.Where(x => ids.Contains(x.QuoteRequestId)).LoadAsync(); await Attachments.Where(x => ids.Contains(x.QuoteRequestId)).LoadAsync(); await QuoteItems.Include(x => x.ProposalPrices) .Where(x => ids.Contains(x.QuoteRequestId)).ToArrayAsync(); await DynamicPropertyObjectValues.Where(x => ids.Contains(x.ObjectId)).LoadAsync(); } return(result); }