private async Task AddApplication(RecivedLoginMessageEvent e)
        {
            using var scope = Services.CreateScope();

            var _ordinationService =
                scope.ServiceProvider
                .GetRequiredService <IOrdinationService>();

            var _applicationService = scope.ServiceProvider
                                      .GetRequiredService <IApplicationService>();

            var ordination = await _ordinationService
                             .GetOrdinationById(Guid.Parse(e.OrdinationId.ToString()));

            var outside = await _applicationService
                          .NumberOutside(ordination.Id);

            if (ordination.MaxOut > outside)
            {
                Application application = new Application();
                application.Id                = Guid.NewGuid();
                application.Ordination        = ordination;
                application.OrdinationId      = ordination.Id;
                application.PatientId         = Guid.Parse(e.PatientId.ToString());
                application.TimeOfApplication = DateTime.Now;
                application.Position          = Status2.Out;

                var inside = await _applicationService.NumberInside(ordination.Id);


                if (ordination.MaxIn > inside)
                {
                    application.Position = Status2.In;
                    inside++;
                }
                else
                {
                    outside++;
                }

                await _applicationService.CreateApplication(application);

                await _signalrHub.Clients.All
                .SendAsync("NumberOfPeople", inside, outside);
            }
            else
            {
                await _signalrHub.Clients.All
                .SendAsync("MaxNumberReached", e.PatientId.ToString(), e.OrdinationId.ToString());
            }
        }
예제 #2
0
 public void Publish(RecivedLoginMessageEvent eventMessage)
 {
     _subject.OnNext(eventMessage);
 }