private PromotionDiscountDTO Map(tblPromotionDiscount tbl)
 {
     var dto = new PromotionDiscountDTO
     {
         MasterId = tbl.id,
         DateCreated = tbl.IM_DateCreated,
         DateLastUpdated = tbl.IM_DateLastUpdated,
         StatusId = tbl.IM_Status,
         ProductMasterId = tbl.ProductRef,
         PromotionDiscountItems = new List<PromotionDiscountItemDTO>()
     };
     foreach (var item in tbl.tblPromotionDiscountItem.Where(n => n.IM_Status == (int)EntityStatus.Active))
     {
         var dtoitem = new PromotionDiscountItemDTO
                           {
                               MasterId = item.id,
                               DateCreated = item.IM_DateCreated,
                               DateLastUpdated = item.IM_DateLastUpdated,
                               StatusId = item.IM_Status,
                               ProductMasterId = item.FreeOfChargeProductRef ?? Guid.Empty,
                               FreeQuantity = item.FreeOfChargeQuantity ?? 0,
                               ParentQuantity = item.ParentProductQuantity,
                               DiscountRate = item.DiscountRate ?? 0,
                               EffectiveDate = item.EffectiveDate,
                               EndDate = item.EndDate ?? DateTime.Now,
                               PromotionDiscountMasterId = item.PromotionDiscountId
                           };
         dto.PromotionDiscountItems.Add(dtoitem);
     }
     return dto;
 }
Exemplo n.º 2
0
 public PromotionDiscountDTO Map(PromotionDiscount promotion)
 {
     if (promotion == null) return null;
     var item = new PromotionDiscountDTO()
                    {
                        DateCreated = promotion._DateCreated,
                        DateLastUpdated = promotion._DateLastUpdated,
                        StatusId = (int) promotion._Status,
                        MasterId = promotion.Id,
                        ProductMasterId = promotion.ProductRef.ProductId,
                        PromotionDiscountItems = promotion.PromotionDiscountItems
                            .Select(s => new PromotionDiscountItemDTO
                                             {
                                                 DateCreated = s._DateCreated,
                                                 DateLastUpdated = s._DateLastUpdated,
                                                 StatusId = (int) s._Status,
                                                 EffectiveDate = s.EffectiveDate,
                                                 EndDate = s.EndDate,
                                                 FreeQuantity = s.FreeOfChargeQuantity,
                                                 ParentQuantity = s.ParentProductQuantity,
                                                 MasterId = s.Id,
                                                 ProductMasterId =
                                                     s.FreeOfChargeProduct == null
                                                         ? Guid.Empty
                                                         : s.FreeOfChargeProduct.ProductId,
                                                 DiscountRate = s.DiscountRate
                                             }).ToList()
                    };
     return item;
 }
Exemplo n.º 3
0
 public PromotionDiscount Map(PromotionDiscountDTO dto)
 {
     if (dto == null) return null;
     var promotionDiscount = Mapper.Map<PromotionDiscountDTO, PromotionDiscount>(dto);
     promotionDiscount.ProductRef = new ProductRef {ProductId = dto.ProductMasterId};
     promotionDiscount.PromotionDiscountItems = dto.PromotionDiscountItems.Select(n => Map(n, n.MasterId)).ToList();
     return promotionDiscount;
 }