/// <summary> /// Action to return details of a rider /// </summary> /// <param name="id">Primary Key</param> /// <returns></returns> public ActionResult ViewDetails(long id) { try { Rider rider = new Rider(id); var temp = rider.GetCompletedRides(); List <Ride> lstTop5CompletedRides; if (temp.Count > 5) { lstTop5CompletedRides = rider.GetCompletedRides().GetRange(0, 5); } else { lstTop5CompletedRides = rider.GetCompletedRides().GetRange(0, temp.Count); } ViewRiderDetailsViewModel model = new ViewRiderDetailsViewModel { CompletedRides = temp.Count, Contact = rider.ContactNumber.LocalFormatedPhoneNumber, Name = rider.FullName.FirstName + " " + rider.FullName.LastName, IsActive = rider.IsActive, Rides = new List <ViewRiderDetailsViewModel.RideDetailsViewModel>(), Id = rider.UserId, IsBlocked = rider.IsBlocked }; foreach (var item in lstTop5CompletedRides) { model.Rides.Add(new ViewRiderDetailsViewModel.RideDetailsViewModel { EndPoint = item.Destination, StartPoint = item.PickUpLocation, Route = item.Route, EndTime = item.DropOffTime.ToString("dd-mm-yyyy hh:mm tt"), StartTime = item.PickUpTime.ToString("dd-mm-yyyy hh:mm tt"), AmountPaid = decimal.Round(item.GetPaymentSummary().GTotal) }); } return(View(model)); } catch (Exception ex) { return(RedirectToAction("ErrorPage", "Error", ex)); } }
public IHttpActionResult GetCompletedRides(long id) { try { Rider rider = new Rider(id); return(Ok(rider.GetCompletedRides())); } catch (Exception ex) { return(InternalServerError(ex)); } }