Esempio n. 1
0
        /// <summary>
        /// Getting TimeAfterDeparture with end time trip.
        /// </summary>
        /// <param name="trip">
        /// Trip object for set end time trip.
        /// </param>
        /// <returns>
        /// Return TimeAfterDeparture object contain info about end trip.
        /// </returns>
        private TimeAfterDeparture GetTimeAfterDepartureEnd(Trip trip)
        {
            //trip is abandon
            if (trip.TimeAfterDeparture == null)
            {
                trip.TimeAfterDeparture = new TimeAfterDeparture();
            }
            else
            {
                trip.TimeAfterDeparture.End = _utilService.DateTimeNow();
            }

            return(trip.TimeAfterDeparture);
        }
Esempio n. 2
0
        public ActionResult Index()
        {
            var id = _userService.GetCurrentUserId();
            IEnumerable <Trip> objList = _repositoryTrip.GetWithIncludeByUserId(id);

            if (objList.Any())
            {
                var trip = objList.First();
                using (var connection = JobStorage.Current.GetConnection())
                {
                    foreach (var recurringJob in connection.GetRecurringJobs())
                    {
                        RecurringJob.RemoveIfExists(recurringJob.Id);
                    }
                }

                var timeDelay = (trip.TimeBeforeDeparture.ApproximateStart - _utilService.DateTimeNow()).Value;
                var idJob     = BackgroundJob.Schedule(() => _tripService.ToHistory(trip.Id), timeDelay);
                BackgroundJob.ContinueJobWith(
                    idJob, () => Response.Redirect(HttpContext.Request.Path));

                BackgroundJob.Schedule(() => Response.Redirect(Request.Path), timeDelay);
            }
            return(View(objList));
        }
Esempio n. 3
0
        public ActionResult Create(Comment comment)
        {
            if (ModelState.IsValid)
            {
                comment.UserId   = _userService.GetCurrentUserId();
                comment.TimePost = _utilService.DateTimeNow();

                _repositoryComment.Add(comment);
                return(RedirectToRoute(new { controller = "Review", action = "Index" }));
            }
            return(View(comment));
        }
Esempio n. 4
0
        public ActionResult Create(Review review)
        {
            if (ModelState.IsValid)
            {
                review.UserId   = _userService.GetCurrentUserId();
                review.TimePost = _utilService.DateTimeNow();

                _repositoryReview.Add(review);
                return(RedirectToRoute(new { controller = "Trip", action = "End", id = review.TripId }));
            }

            return(View("Trip/Start/", review));
        }