コード例 #1
0
        public Response AddUserToTrip(string tripId)
        {
            var isAdded = tripService.IsAddedToTrip(tripId, User.Id);

            if (isAdded)
            {
                return(Redirect($"/Trips/Details?tripId={tripId}"));
                ///Trips/Details?tripId=65235c4e-ddf8-4ced-b184-174ed09edacf
            }

            try
            {
                tripService.AddUSerToTrip(tripId, User.Id);
            }
            catch (ArgumentException aex)
            {
                return(View(new List <ErrorViewModel>()
                {
                    new ErrorViewModel(aex.Message)
                }));
            }
            catch (Exception)
            {
                return(View(new List <ErrorViewModel>()
                {
                    new ErrorViewModel("Unexpected error!")
                }));
            }

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