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;
 }
Example #2
0
 public PromotionDiscount.PromotionDiscountItem Map(PromotionDiscountItemDTO dto, Guid id)
 {
     if (dto == null) return null;
     var item = Mapper.Map<PromotionDiscountItemDTO, PromotionDiscount.PromotionDiscountItem>(dto);
     item.FreeOfChargeProduct = new ProductRef {ProductId = dto.ProductMasterId};
     item._Status = EntityStatus.New; 
     return item;
 }