public ActionResult UnRentItem()
        {
            string      appId  = User.Identity.GetUserId();
            Leasor      leasor = context.Leasors.Where(r => r.ApplicationId == appId).FirstOrDefault();
            List <Item> items  = context.Items.Where(i => i.LeasorId == leasor.LeasorId).ToList();

            foreach (Item item in items)
            {
                if (DateTime.Now >= item.EndDate)
                {
                    Renter renter = context.Renters.Where(r => r.RenterId == item.RenterId).FirstOrDefault();
                    item.Availability = true;
                    item.StartDate    = null;
                    item.EndDate      = null;
                    item.RenterId     = null;
                    RatingQueue ratingQueue = new RatingQueue();
                    ratingQueue.LeasorId = leasor.LeasorId;
                    ratingQueue.RenterId = renter.RenterId;
                    context.RatingQueues.Add(ratingQueue);
                    context.SaveChanges();
                    sendText.SendSMSToRenterForRentPeriodEnding(renter);
                    //RedirectToAction("Create", "Ratings", rating);
                }
            }
            return(RedirectToAction("Index", "Home"));
        }
Ejemplo n.º 2
0
 /// <summary>
 /// Enqueues a UnBan request but does not send it. Call <see cref="Process"/> to send
 /// </summary>
 /// <param name="track">The <see cref="Track"/> that has played</param>
 /// <remarks>This method is thread-safe. Will not check for invalid tracks until Processed.</remarks>
 public void UnBan(Track track)
 {
     RatingQueue.Enqueue(new RatingObject()
     {
         Track = track, RatingType = Rating.unban
     });
 }
Ejemplo n.º 3
0
 /// <summary>
 /// Enqueues a UnLove request but does not send it. Call <see cref="Process"/> to send
 /// </summary>
 /// <param name="track">The <see cref="Track"/> that has played</param>
 /// <remarks>This method is thread-safe. Will not check for invalid tracks until Processed.</remarks>
 public void UnLove(Track track)
 {
     RatingQueue.Enqueue(new RatingObject()
     {
         Track = track, RatingType = Rating.unlove
     });
 }
 public ActionResult Create(RatingQueue ratingQueue)
 {
     try
     {
         // TODO: Add insert logic here
         context.RatingQueues.Add(ratingQueue);
         context.SaveChanges();
         return(RedirectToAction("Index"));
     }
     catch
     {
         return(View());
     }
 }
        // GET: RatingQueues/Create
        public ActionResult Create()
        {
            RatingQueue ratingQueue = new RatingQueue();

            return(View());
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Synchronously processes all scrobbles and now playing notifications that are in the Queues, and returns the results
        /// </summary>
        /// <param name="throwExceptionDuringProcess">When true, will throw the first Exception encountered during Scrobbling (and cease to process).
        /// When false, any exceptions raised will be attached to the corresponding <see cref="ScrobbleResponse"/>, but will not be thrown. Default is false.</param>
        /// <returns><see cref="ScrobbleResponses"/>, a list of <see cref="ScrobbleResponse"/> </returns>
        /// <remarks>This method will complete synchronously and may take some time. This should be invoked by a single timer. This
        /// method may not be thread safe</remarks>
        public List <Response> Process(bool throwExceptionDuringProcess = false)
        {
            if (string.IsNullOrEmpty(SessionKey))
            {
                return(null);
            }
            var results = new List <Response>();

            Track track;

            while (NowPlayingQueue.TryDequeue(out track))
            {
                try
                {
                    results.Add(_scrobbler.NowPlaying(track));
                }
                catch (Exception exception)
                {
                    if (throwExceptionDuringProcess)
                    {
                        throw;
                    }
                    results.Add(new NowPlayingResponse {
                        Track = track, Exception = exception
                    });
                }
            }

            while (ScrobbleQueue.TryDequeue(out track))
            {
                //TODO: Implement bulk scrobble
                try
                {
                    results.Add(_scrobbler.Scrobble(track));
                }
                catch (Exception exception)
                {
                    if (throwExceptionDuringProcess)
                    {
                        throw;
                    }
                    results.Add(new ScrobbleResponse {
                        Track = track, Exception = exception
                    });
                }
            }

            RatingObject rating;

            while (RatingQueue.TryDequeue(out rating))
            {
                try
                {
                    switch (rating.RatingType)
                    {
                    case Rating.love:
                        results.Add(_scrobbler.Love(rating.Track));
                        break;

                    case Rating.ban:
                        results.Add(_scrobbler.Ban(rating.Track));
                        break;

                    case Rating.unlove:
                        results.Add(_scrobbler.UnLove(rating.Track));
                        break;

                    case Rating.unban:
                        results.Add(_scrobbler.UnBan(rating.Track));
                        break;
                    }
                }
                catch (Exception exception)
                {
                    if (throwExceptionDuringProcess)
                    {
                        throw;
                    }
                    results.Add(new RatingResponse {
                        ErrorCode = -1, Exception = exception, Track = rating.Track
                    });
                }
            }

            return(results);
        }