示例#1
0
        public PromotionModel GetPromotionForMembership()
        {
            PromotionModel promotion = null;

            try
            {
                promotion = promotionRepository
                            .FindBy(p => p.IsActive == true &&
                                    p.OnlyMembership == true &&
                                    p.StartDate <= DateTime.Now && p.EndDate >= DateTime.Now)
                            .OrderByDescending(p => p.StartDate)
                            .Select(p => new PromotionModel
                {
                    Id             = p.Id,
                    Name           = p.Name,
                    StartDate      = p.StartDate,
                    EndDate        = p.EndDate,
                    Saleoff        = p.Saleoff,
                    OnlyMembership = p.OnlyMembership,
                }).FirstOrDefault();
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return(promotion);
        }