public IActionResult GetUserPublicTrips() { string userId = GetUserId(); if (userId == "error") { return(Unauthorized()); } var publicTrips = _publicTripService.GetMultiDescByDate(s => s.ApplicationUserId == userId && s.IsDeleted != true, s => s.ArrivalDate, null).ToList(); return(Ok(publicTrips)); }
public IActionResult GetPublicTrips() { string userId; try { userId = User.Claims.First(c => c.Type == "UserID").Value; } catch { return(Unauthorized()); } var user = _userService.GetSingleByCondition(s => s.Id == userId, null); string[] includes = { "User" }; if (user.Address == null) { return(Ok(new List <PublicTrip>())); } var publicTrips = _publicTripService.GetMultiDescByDate(s => s.ApplicationUserId != userId && s.IsDeleted != true && DateTime.Compare((DateTime)s.ArrivalDate, DateTime.Now) >= 0 && s.Destination.Equals(user.Address), s => s.ArrivalDate, includes).Take(5).ToList(); return(Ok(publicTrips)); }