public static Reservation GetReservation(int id) { if (id >= 0) //existing user { return(ReservationDao.Find(id)); } else if (id == -1) //new user or no user { return(new Reservation()); } return(null); }
public static int SaveReservation(int reservationId, int clientId, int userId, string destination, string hotel, int people, string details, int totalPrice, int paid, DateTime deadline, DateTime date) { if (reservationId >= 0) //existing reservation { var r = ReservationDao.Find(reservationId); r.ClientId = clientId; r.UserId = userId; r.Destination = destination; r.HotelName = hotel; r.PersonCount = people; r.Details = details; r.TotalPrice = totalPrice; r.PaidAmount = paid; r.FinalPaymentDate = deadline; r.ReservationDate = date; ReservationDao.Update(r); return(r.Id); } else if (reservationId == -1) //new reservation { var r = new Reservation(); r.ClientId = clientId; r.UserId = userId; r.Destination = destination; r.HotelName = hotel; r.PersonCount = people; r.Details = details; r.TotalPrice = totalPrice; r.PaidAmount = paid; r.FinalPaymentDate = deadline; r.ReservationDate = date; r = ReservationDao.InsertReservation(r); return(r.Id); } return(-1); }