public Trip Create(int fromTownId, int toTownId, DateTime dateOfLeaving, int availableSeats, string placeOfLeaving, bool pickUpFromAddress, string description, DateTime eta, decimal price, string driverId) { Trip trip = new Trip() { DateOfLeaving = dateOfLeaving, FromId = fromTownId, ToId = toTownId, DriverId = driverId, Description = description, ETA = eta, PlaceOfLeaving = placeOfLeaving, PickUpFromAddress = pickUpFromAddress, AvailableSeats = availableSeats, Price = price }; this.tripRepos.Add(trip); this.tripRepos.Save(); this.tripRepos.Reload(trip); return trip; }
public void Update(Trip trip) { this.trips.Update(trip); this.trips.SaveChanges(); }
public void MarkAsDeleted(Trip trip) { this.trips.MarkAsDeleted(trip); this.trips.SaveChanges(); }
public void Add(Trip trip) { this.trips.Add(trip); this.trips.SaveChanges(); }
public int GetLikesCount(Trip trip) { int likes = trip.Likes .Where(l => l.IsDeleted == false && l.Value == true) .Count(); int dislikes = trip.Likes .Where(l => l.IsDeleted == false && l.Value == false) .Count(); int likesCount = likes - dislikes; return likesCount; }
public bool CheckIfUserLikedTrip(Trip trip, string userId) { Like like = trip.Likes .Where(l => l.UserId == userId && l.IsDeleted == false) .FirstOrDefault(); if (like != null) { return like.Value; } return false; }
public BaseSignalRModel NotifyTripPassengersAndDriverForTripFinish(Trip trip, string userId) { var passengerIds = trip.Passengers .Where(p => p.Approved == true && p.IsDeleted == false) .Select(p => p.UserId) .ToList(); foreach (var passengerId in passengerIds) { this.notificationServices.Create( trip.Id, userId, passengerId, NotificationConstants.TripFinishTitle, string.Format(NotificationConstants.TripFinishRequestPassengerFormat, trip.Driver.UserName, trip.From.Name, trip.To.Name, trip.DateOfLeaving.ToString("dd/MM/yyyy HH:mm")), NotificationKey.TripFinished, DateTime.Now.AddDays(7)); } this.notificationServices.Create( trip.Id, userId, trip.DriverId, NotificationConstants.TripFinishTitle, string.Format(NotificationConstants.TripFinishRequestDriverFormat, trip.From.Name, trip.To.Name, trip.DateOfLeaving.ToString("dd/MM/yyyy HH:mm")), NotificationKey.TripFinished, DateTime.Now.AddDays(7)); return this.notificationServices.SendNotifications(passengerIds); }
public IQueryable<PassengerTrip> GetPassengers(Trip trip) { var passengers = this.passengerTripsRepos.All() .Where(pt => pt.Trip == trip && pt.Approved == true && pt.IsDeleted == false) .OrderBy(pt => pt.CreatedOn); return passengers; }