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) { 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")); }