public void SetReservation(TimeshiftReservationDetailItem reservationInfo) { Reservation = reservationInfo; ReservationStatus = LiveStatus is LiveStatus.Onair ? null : reservationInfo?.GetReservationStatus(); DeleteReservationCommand.NotifyCanExecuteChanged(); AddReservationCommand.NotifyCanExecuteChanged(); }
public ReservationsViewModel() { addReservationCommand = new AddReservationCommand(this); updateReservationCommand = new UpdateReservationCommand(this); deleteReservationCommand = new DeleteReservationCommand(this); changeDayTherapistReservation = new ChangeDayTherapistReservation(this); DateTime currentTime = DateTime.Now; DateTime dataVisitStart = new DateTime(2019, 12, 23, 08, 30, 00); DateTime dataVisitEnd = new DateTime(2019, 12, 23, 09, 30, 00); DatesReservations = new ObservableCollection <DateTime> { DateTime.Today }; therapistsListToReservation = new ObservableCollection <string> { }; readPatients(); readTherapists(); reservationsList = new ObservableCollection <ReservationModel> { }; //DataGrid_Loaded(); DataGridReservation_Loaded(); }
public async Task DeleteReservation_NewReservation_SuccessfullyMissing() { IServiceCollection services = new ServiceCollection(); services.AddHostingDomain() .AddHostingApplication() .AddHostingInfrastructure("Server=.;Database=RestaurantManagementSystem;Trusted_Connection=True;MultipleActiveResultSets=true", "S0M3 M4G1C UN1C0RNS G3N3R4T3D TH1S S3CR3T"); var serviceProviderFactory = new DefaultServiceProviderFactory(); IServiceProvider serviceProvider = serviceProviderFactory.CreateServiceProvider(services); IMediator Mediator = serviceProvider.GetService <IMediator>(); var createTableCommand = new CreateTableCommand(); createTableCommand.Indoor = true; createTableCommand.Location = "Do Prozoreca"; createTableCommand.Name = "Bestest Table EVER"; createTableCommand.NumberOfSeats = 6; createTableCommand.SmokingAllowed = true; createTableCommand.RestaurantName = "Best Restaurant EVER"; var createTableOutputModel = await Mediator.Send(createTableCommand); var tommorow = DateTime.UtcNow.AddDays(1); var addReservationCommand = new AddReservationCommand(); addReservationCommand.TableId = createTableOutputModel.TableId; addReservationCommand.Start = new DateTime(tommorow.Year, tommorow.Month, tommorow.Day, 13, 30, 0); addReservationCommand.Guest = new Guest("Goshko", "Loshkov", "0900tainamaina"); var addReservationOutput = await Mediator.Send(addReservationCommand); var deleteReservationCommand = new DeleteReservationCommand(); deleteReservationCommand.ReservationId = addReservationOutput.ReservationId; await Mediator.Send(deleteReservationCommand); var getTablesQuery = new GetTablesQuery(); var getTablesOutput = await Mediator.Send(getTablesQuery); var dbTable = getTablesOutput.Tables.FirstOrDefault(table => table.Id == createTableOutputModel.TableId); var targetSchedule = dbTable.GetScheduleForDateTime(addReservationCommand.Start); await Assert.ThrowsExceptionAsync <InvalidOperationException>(() => { var targetRes = targetSchedule.Reservations.First(res => res.Id == addReservationOutput.ReservationId); return(Task.CompletedTask); }); }
private async Task <Reservation> CreateReservationWithPendingStatus(User user, Resource resource, AddReservationCommand reservation) { var status = DomainReservationStatus.ReservationStatuses[DomainReservationStatus.Pending]; var newReservation = await _reservations .CreateNewReservation(reservation.StartTime, reservation.EndTime, resource, user, reservation.AllowNotifications); await ChangeStatus(new ChangeStatusCommand { Reason = "Created by user", ChangedBy = user, ChangeTo = status, Reservation = _mapper.Map <DomainReservation>(newReservation) }); return(newReservation); }
public ReservationsViewModel(AccommodationUnit unit, HomePageViewModel homePageViewModel) { HomePageViewModel = homePageViewModel; if (unit != null) { Unit = unit; Reservations = ReservationService.GetReservations(Unit.Id, Unit.Accommodation.Id); UnitString = "Floor : " + Unit.Floor + ", Number : " + Unit.Number; } else { Reservations = ReservationService.GetReservations(0, HomePageViewModel.Accommodation.Id); } //EnableUpdate = false; //EnableDelete = false; AddReservationCommand = new AddReservationCommand(Unit, Reservation, this); UpdateReservationCommand = new UpdateReservationCommand(this); DeleteReservationCommand = new DeleteReservationCommand(this); }
public async Task AddOverlappingReservation_NewReservation_ThrowsError() { IServiceCollection services = new ServiceCollection(); services.AddHostingDomain() .AddHostingApplication() .AddHostingInfrastructure("Server=.;Database=RestaurantManagementSystem;Trusted_Connection=True;MultipleActiveResultSets=true", "S0M3 M4G1C UN1C0RNS G3N3R4T3D TH1S S3CR3T"); var serviceProviderFactory = new DefaultServiceProviderFactory(); IServiceProvider serviceProvider = serviceProviderFactory.CreateServiceProvider(services); IMediator Mediator = serviceProvider.GetService <IMediator>(); var createTableCommand = new CreateTableCommand(); createTableCommand.Indoor = true; createTableCommand.Location = "Do Prozoreca"; createTableCommand.Name = "Bestest Table EVER"; createTableCommand.NumberOfSeats = 6; createTableCommand.SmokingAllowed = true; createTableCommand.RestaurantName = "Best Restaurant EVER"; var createTableOutputModel = await Mediator.Send(createTableCommand); var tommorow = DateTime.UtcNow.AddDays(1); var addReservationCommand = new AddReservationCommand(); addReservationCommand.TableId = createTableOutputModel.TableId; addReservationCommand.Start = new DateTime(tommorow.Year, tommorow.Month, tommorow.Day, 13, 30, 0); addReservationCommand.Guest = new Guest("Goshko", "Loshkov", "0900tainamaina"); var addReservationOutput = await Mediator.Send(addReservationCommand); addReservationCommand = new AddReservationCommand(); addReservationCommand.TableId = createTableOutputModel.TableId; addReservationCommand.Start = new DateTime(tommorow.Year, tommorow.Month, tommorow.Day, 13, 30, 0); addReservationCommand.Guest = new Guest("Goshko", "Loshkov", "0900tainamaina"); await Assert.ThrowsExceptionAsync <ReservationConflictException>(() => { return(Mediator.Send(addReservationCommand)); }); }
public async Task <DomainReservation> AddNewReservation(AddReservationCommand cmd) { // User must exist var user = await _users.FindById(cmd.UserId) ?? throw new EntityNotFoundException(nameof(User), $"id == {cmd.UserId}"); // Resource must exist var resource = await _resources.FindById(cmd.ResourceId) ?? throw new EntityNotFoundException(nameof(Resource), $"id == {cmd.ResourceId}"); var collisions = await GetCollisionsFor(resource, cmd.StartTime, cmd.EndTime); // there are already Reservations for the specified time slot if (collisions.Count != 0) { throw new ReservationCollisionException(); } var reservation = await CreateReservationWithPendingStatus(user, resource, cmd); return(_mapper.Map <DomainReservation>(reservation)); }
public async Task <ActionResult <AddReservationOutputModel> > AddReservation(AddReservationCommand addReservationCommand) { return(await Send(addReservationCommand)); }