private ProductDiscountDTO Map(tblDiscounts tbl,DateTime from)
 {
     var dto = new ProductDiscountDTO
     {
         MasterId = tbl.id,
         DateCreated = tbl.IM_DateCreated,
         DateLastUpdated = tbl.IM_DateLastUpdated,
         StatusId = tbl.IM_Status,
         ProductMasterId = tbl.ProductRef,
         TierMasterId = tbl.TierId,
         DiscountItem = new List<ProductDiscountItemDTO>()
     };
     foreach (var item in tbl.tblDiscountItem.Where(n => n.IM_Status == (int)EntityStatus.Active))
     {
         var dtoitem = new ProductDiscountItemDTO
                           {
                               MasterId = item.id,
                               DateCreated = item.IM_DateCreated,
                               DateLastUpdated = item.IM_DateLastUpdated,
                               StatusId = item.IM_Status,
                               DiscountRate = item.DiscountRate,
                               EffectiveDate = item.EffectiveDate,
                               EndDate = item.EndDate ?? DateTime.Now,
                               IsByQuantity = item.IsByQuantity,
                               Quantity = item.Quantity,
                               
                           };
         dto.DiscountItem.Add(dtoitem);
     }
     dto.DeletedProductDiscountItem = tbl.tblDiscountItem.Where(n => n.IM_Status == (int)EntityStatus.Inactive && n.IM_DateLastUpdated > from).Select(s => s.id).ToList();
    
     return dto;
 }
 public ProductDiscountDTO Map(ProductDiscount productDiscount)
 {
     if (productDiscount == null) return null;
     var item = new ProductDiscountDTO()
                    {
                        DateCreated = productDiscount._DateCreated,
                        DateLastUpdated = productDiscount._DateLastUpdated,
                        StatusId = (int)productDiscount._Status,
                        MasterId = productDiscount.Id,
                        ProductMasterId = productDiscount.ProductRef.ProductId,
                        TierMasterId = productDiscount.Tier.Id,
                        DiscountItem = productDiscount.DiscountItems
                            .Select(s => new ProductDiscountItemDTO
                                             {
                                                 DateCreated = s._DateCreated,
                                                 DateLastUpdated = s._DateLastUpdated,
                                                 DiscountRate = s.DiscountRate,
                                                 EffectiveDate = s.EffectiveDate,
                                                 EndDate = s.EndDate,
                                                 StatusId = (int)s._Status,
                                                 MasterId = s.Id,
                                             }
                            ).ToList()
                    };
     return item;
 }
Example #3
0
 public ProductDiscount Map(ProductDiscountDTO dto)
 {
     if (dto == null) return null;
     var productDiscount = Mapper.Map<ProductDiscountDTO, ProductDiscount>(dto);
     productDiscount.Tier = _pricingTierRepository.GetById(dto.TierMasterId);
     productDiscount.ProductRef = new ProductRef {ProductId = dto.ProductMasterId};
     productDiscount.DiscountItems = dto.DiscountItem.Select(n => Map(n, n.MasterId)).ToList();
     return productDiscount;
 }