示例#1
0
        public async Task <SurgeryRequest> CreateSurgeryRequest(DateTime start, DateTime end, Patient patient, Doctor requester, Doctor proposedDoctor, bool isUrgent, DateTime timestamp, Room room)
        {
            await using var context = ContextFactory.CreateDbContext();
            var surgeryRequest = new SurgeryRequest();
            var request        = (await context.SurgeryRequests.AddAsync(surgeryRequest)).Entity;

            request.IsActive       = true;
            request.Room           = room;
            request.StartDate      = start;
            request.EndDate        = end;
            request.IsApproved     = false;
            request.Patient        = patient;
            request.Requester      = requester;
            request.ProposedDoctor = proposedDoctor;
            request.IsUrgent       = isUrgent;


            await using var context1 = ContextFactory.CreateDbContext();
            context1.SurgeryRequests.Update(request);
            await context.SaveChangesAsync();

            await _notificationService.PublishSurgeryRequestNotification(request, timestamp, string.Empty);

            return(request);
        }
        public async Task <SurgeryRequestNotification> PublishSurgeryRequestNotification(SurgeryRequest surgeryRequest, DateTime timestamp, string message)
        {
            var notification = new SurgeryRequestNotification();

            await Create(notification);

            notification.IsActive       = true;
            notification.SurgeryRequest = surgeryRequest;
            notification.Timestamp      = timestamp;
            notification.Status         = NotificationStatus.Unread;
            notification.Message        = message;

            return(await Update(notification) as SurgeryRequestNotification);
        }