public static void ExpireCoupon() { List <CouponDTO> CouponDTOList = new List <CouponDTO>(); CouponDTOList = CouponService.GetCouponListWhichNotExpired(); if (CouponDTOList != null) { foreach (var item in CouponDTOList) { EcouponCampaignDTO EcouponCampaignDTO = new EcouponCampaignDTO(); EcouponCampaignDTO = EcouponCampaignService.GetById(item.EcouponCampaignId); if (EcouponCampaignDTO.ExpiresOn != null) { if (EcouponCampaignDTO.ExpiresOn < System.DateTime.Now) { CouponDTO CouponDTO = new CouponDTO(); CouponDTO = item;// CouponService.GetById(item.Id); CouponDTO.IsExpired = true; CouponService.Edit(CouponDTO); } } } } }