public bool UpdateBooking(BookingViewModel booking) { try { var existingBooking = _context.Bookings.Where(w => w.BookingID == booking.ID) .FirstOrDefault <Booking>(); if (existingBooking != null) { existingBooking.Cost = booking.Cost; existingBooking.EndingPoint = booking.EndingPoint; existingBooking.IsAccepted = booking.IsAccepted; existingBooking.RentalOfferID = booking.RentalOfferID; existingBooking.SeatsNeeded = booking.SeatsNeeded; existingBooking.StartingPoint = booking.StartingPoint; existingBooking.UserID = booking.UserID; existingBooking.Date = booking.Date; existingBooking.Time = booking.Time; existingBooking.IsRejected = booking.IsRejected; _context.SaveChanges(); } return(true); } catch (Exception e) { return(false); } }
public bool UpdateRentalOffer(RentalOfferViewModel rentalOffer) { try { var existingRentalOffer = _context.RentalOffers.Where(r => r.RentalOfferID == rentalOffer.ID) .FirstOrDefault <RentalOffer>(); if (existingRentalOffer != null) { existingRentalOffer.EndingPoint = rentalOffer.EndingPoint; existingRentalOffer.IsClosed = rentalOffer.IsClosed; existingRentalOffer.MoneyRecieved = rentalOffer.MoneyRecieved; existingRentalOffer.SeatsAvailable = rentalOffer.SeatsAvailable; existingRentalOffer.StartingPoint = rentalOffer.StartingPoint; existingRentalOffer.Date = rentalOffer.Date; existingRentalOffer.Time = rentalOffer.Time; existingRentalOffer.UserID = rentalOffer.UserID; existingRentalOffer.VehicleID = rentalOffer.VehicleID; existingRentalOffer.OfferPrice = rentalOffer.OfferPrice; existingRentalOffer.ViaPoints = rentalOffer.ViaPoints; _context.SaveChanges(); } return(true); } catch (Exception e) { return(false); } }
public bool AddUser(UserViewModel User) { try { _context.Users.Add(_mapper.Map <User>(User)); _context.SaveChanges(); return(true); } catch (Exception e) { return(false); } }
public bool AddRating(RatingViewModel rating) { try { _context.Ratings.Add(_mapper.Map <Rating>(rating)); _context.SaveChanges(); return(true); } catch (Exception e) { return(false); } }
public bool UpdateBalance(WalletViewModel wallet) { try { var existingWallet = _context.Wallets.Where(w => w.User.UserID == wallet.ID) .FirstOrDefault <Wallet>(); if (existingWallet != null) { existingWallet.balance += wallet.balance; _context.SaveChanges(); } return(true); } catch (Exception e) { return(false); } }
public bool AddVehicle(VehicleViewModel vehicle) { try { _context.Vehicles.Add(_mapper.Map <Vehicle>(vehicle)); _context.SaveChanges(); return(true); } catch (Exception e) { return(false); } }
public void AddPayment(Payment payment) { CarpoolContext.Payments.Add(payment); CarpoolContext.SaveChanges(); }