public bool ReserveRoom(RoomReservation aRoomReservation) { var data = new RoomReservationRepository(); data.ReserveRoom(aRoomReservation); return(true); }
public RoomReservation[] GetRoomReservations(DateTime fromTime, DateTime toTime) { WriteLine("received call to return reservations"); var data = new RoomReservationRepository(); return(data.GetReservations(fromTime, toTime)); }
public string PayReservation(int userId, decimal amountPayed, DateTime datePaied) { using (var uow = UnitOfWorkProvider.Create()) { var reservation = RoomReservationRepository.GetById(userId); var user = UserRepository.GetById(userId); if (user == null) { throw new UIException("Neexistuje užívateľ korého registráciu sa snažíte zaplatiť"); } if (reservation == null) { reservation = new RoomReservation { Id = userId, AmountPayed = amountPayed, DatePaid = datePaied, Note = string.Empty }; RoomReservationRepository.Insert(reservation); } else { reservation.AmountPayed = amountPayed; reservation.DatePaid = datePaied; } uow.Commit(); return(user.UserName); } }
//在AspNetCore MVC 或 API 中可以使用依赖注入,将RoomReservationRepository 通过构造函数注入到服务中 public bool ReserveRoom(RoomReservation roomReservation) { //在约束 类库中 定义数据结构 定义访问数据需要实现的方法 //在数据 类库中 实现数据类与数据库之间的交互 //在服务 类库中 实现与APP的交互 隔离数据类和数据访问 var data = new RoomReservationRepository(); data.RoomReservation(roomReservation); return(true); }
public UnitOfWork(IDataService dataService) { _dataService = dataService; User = new UserRepository(_dataService); Company = new CompanyRepository(_dataService); Room = new RoomRepository(_dataService); StayType = new StayTypesRepository(_dataService); Guest = new GuestRepository(_dataService); Reservation = new ReservationRepository(_dataService); RoomReservation = new SchedulerRepository(_dataService); RoomReservationRepository = new RoomReservationRepository(_dataService); }
public bool ReserveRoom(RoomReservation roomReservation) { try { var data = new RoomReservationRepository(); data.ReserveRoom(roomReservation); } catch (Exception ex) { RoomReservationFault fault = new RoomReservationFault { Message = ex.Message }; throw new FaultException <RoomReservationFault>(fault); } return(true); }
public override RoomReservationDto Create() { using (UnitOfWorkProvider.Create()) { if (UserRepository.GetById(CurrentUserId) == null) { throw new UIException("Neplatné Id užívateľa. pri vytváraní rezervácie izby. Thats not good..."); } return(new RoomReservationDto { Id = (RoomReservationRepository.GetById(CurrentUserId) == null) ? 0 : CurrentUserId, UserId = CurrentUserId }); } }
public bool ReserveRoom(RoomReservation roomReservation) { try { WriteLine($"received room reservation for room {roomReservation.RoomName}"); var data = new RoomReservationRepository(); data.ReserveRoom(roomReservation); } catch (Exception ex) { WriteLine($"error {ex.Message}"); RoomReservationFault fault = new RoomReservationFault { Message = ex.Message }; throw new FaultException <RoomReservationFault>(fault); } return(true); }
public RoomReservation[] GetRoomReservations(DateTime fromTime, DateTime toTime) { var data = new RoomReservationRepository(); return(data.GetReservations(fromTime, toTime)); }