示例#1
0
        public HttpResponse AddUserToTrip(string tripId)
        {
            if (!User.IsAuthenticated)
            {
                //return Redirect("/Users/Login");

                return(Error($"401 Unauthorized")); // This way is more ser-friendly
            }

            var userId = User.Id;

            if (tripsService.IsUserInTrip(userId, tripId))
            {
                return(Redirect($"/Trips/Details?tripId={tripId}"));
            }

            if (tripsService.HasAvaibleSeats(tripId))
            {
                return(Error("No seats avaible."));
            }

            tripsService.AddUserToTrip(userId, tripId);

            return(Redirect("/Trips/All"));
        }
示例#2
0
        public HttpResponse AddUserToTrip(string tripId)
        {
            try
            {
                tripsService.AddUserToTrip(tripId, this.User.Id);
            }
            catch (Exception aex)
            {
                return(Error(aex.Message));
            }

            return(Redirect("/Trips/All"));
        }
示例#3
0
        public HttpResponse AddUserToTrip(string tripId)
        {
            if (this.IsUserLoggedIn())
            {
                var added = tripService.AddUserToTrip(tripId, this.User);
                if (added)
                {
                    return(this.Redirect($"/Trips/All"));
                }

                return(this.Details(tripId));
            }

            return(this.Redirect($"/"));
        }
示例#4
0
        public HttpResponse AddUserToTrip(string tripId)
        {
            if (!IsUserSignIn())
            {
                return(Redirect("/Users/Login"));
            }

            var userId = GetUserId();

            if (tripsService.IsUserInTrip(userId, tripId))
            {
                return(Redirect($"/Trips/Details?tripId={tripId}"));
            }

            if (tripsService.HasAvaibleSeats(tripId))
            {
                return(Error("No seats avaible."));
            }

            tripsService.AddUserToTrip(userId, tripId);

            return(Redirect("/Trips/All"));
        }