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")); }
public HttpResponse AddUserToTrip(string tripId) { try { tripsService.AddUserToTrip(tripId, this.User.Id); } catch (Exception aex) { return(Error(aex.Message)); } return(Redirect("/Trips/All")); }
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($"/")); }
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")); }