/// <summary>
        /// Works only for sales listing for now
        /// </summary>
        /// <param name="subcategory"></param>
        /// <returns></returns>
        public Subscription CreateSubscription(eSubscription subcategory)
        {
            Subscription newsub = new Subscription
            {
                ExpirationDate       = CalculateExpirationDate(subcategory),
                SubscriptionType     = eSubscriptionType.SaleListing,
                SubscriptionCategory = subcategory
            };

            return(newsub);
        }
Exemple #2
0
 public IHttpActionResult AddOrUpdateSubscription(eSubscription sub, [FromBody] SaleListingDTO salelistingviewmodel)
 {
     if (ModelState.IsValid)
     {
         if (_salelistingService.AddOrUpdateSubscription(sub, salelistingviewmodel))
         {
             return(Ok());
         }
         return(NotFound());
     }
     return(BadRequest(ModelState));
 }
Exemple #3
0
 public bool AddOrUpdateSubscription(eSubscription sub, SaleListingDTO salelistingviewmodel)
 {
     try
     {
         SaleListing  salelisting  = _saleListingRepository.GetSaleListing(salelistingviewmodel.ID);
         Subscription subscription = _subscriptionService.CreateSubscription(sub);
         _saleListingRepository.UpdateSaleListingSubscription(salelisting, subscription);
         //_log.LogSaleListing(salelisting.Owner.ID, salelisting.ID, eLogSaleListingType.Update);
         return(true);
     }
     catch (Exception ex)
     {
         return(false);
     }
 }
        public DateTime CalculateExpirationDate(eSubscription subcategory)
        {
            DateTime expirationDate = DateTime.Now;

            switch (subcategory)
            {
            case eSubscription.None:
                expirationDate = DateTime.Now;
                break;

            case eSubscription.Basic:
            case eSubscription.Medium:
            case eSubscription.Premium:
                expirationDate = DateTime.Now.AddDays(7);
                break;
            }
            return(expirationDate);
        }