Beispiel #1
0
        public bool RenewMyAd(int adId)
        {
            var now = DateTime.Now;
            var ad  = CurrentDbContext.ClassifiedDB.Include("Poster").SingleOrDefault(x => x.Id == adId && x.Poster.Id == UserId);

            if (ad == null || ad.ExpiryTimeStamp.Value.Subtract(now).Days > 14)
            {
                return(false);
            }
            ad.ExpiryTimeStamp = ExpiryDate.CalculateDate(DateTime.Now, ad.AdType, ad.Category.Name, ad.SubCategory.Name);
            CurrentDbContext.SaveChanges();
            HangfireManager.ScheduleDateCheck(ad.Id, DateTime.Now, ad.ExpiryTimeStamp.Value);
            return(true);
        }