public void CoAQueueHearingAsync()
        {
            // civil case
            // case number = "CA39029"
            // case id = 37351

            // hearingLength = "Half" or "Full" (not case sensitive)

            // criminal case
            // case number = "CA42024"
            // case id = 40368

            // Hearing Type
            // - civil hearing of appeal = 24
            // - criminal hearing of appeal = 72
            // - criminal conviction appeal = 96
            // - criminal sentence appeal = 97

            var booking = new CoABookingHearingInfo
            {
                caseID        = 37351,
                email         = "*****@*****.**",
                hearingDate   = DateTime.Parse("2019/11/08 00:00:00.0000000"),
                hearingLength = "Full",
                phone         = "778-865-7042",
                hearingTypeId = 24,
                requestedBy   = "Mike Olund"
            };

            BookingHearingResult result = _soapClient.CoAQueueHearingAsync(booking).Result;
        }
Esempio n. 2
0
        public void BookingHearingSuccess()
        {
            const int trialManagementConference = 9090;

            var booking = new BookHearingInfo
            {
                CEIS_Physical_File_ID = 3879m,
                containerID           = 305273,
                dateTime      = new DateTime(2019, 2, 25, 11, 45, 0),
                hearingLength = 30,
                hearingTypeId = trialManagementConference,
                locationID    = 1,
                requestedBy   = "John Smith 604-555-1212 [email protected]"
            };

            BookingHearingResult result = _soapClient.BookingHearingAsync(booking).Result;

            Assert.NotNull(result);
        }
Esempio n. 3
0
        public void BookingHearingFail()
        {
            // this booking will fail because the date is too close in the future

            const int trialManagementConference = 9090;

            var booking = new BookHearingInfo
            {
                CEIS_Physical_File_ID = 3879m,
                containerID           = 305291,
                dateTime      = new DateTime(2019, 1, 22, 11, 45, 0),
                hearingLength = 30,
                hearingTypeId = trialManagementConference,
                locationID    = 1,
                requestedBy   = "John Smith 604-555-1212 [email protected]"
            };

            BookingHearingResult result = _soapClient.BookingHearingAsync(booking).Result;

            Assert.NotNull(result);
        }
Esempio n. 4
0
        /// <summary>
        ///     Book court case
        /// </summary>
        public async Task <ScCaseConfirmViewModel> BookCourtCase(ScCaseConfirmViewModel model,
                                                                 string userGuid, string userDisplayName)
        {
            //if the user could not be detected return
            if (string.IsNullOrWhiteSpace(userGuid))
            {
                return(model);
            }

            ScSessionBookingInfo bookingInfo = _session.ScBookingInfo;

            // check the schedule again to make sure the time slot wasn't taken by someone else
            AvailableDatesByLocation schedule =
                await _client.AvailableDatesByLocationAsync(
                    bookingInfo.BookingRegistryId,
                    bookingInfo.HearingTypeId);

            //ensure time slot is still available
            if (IsTimeStillAvailable(schedule, bookingInfo.ContainerId))
            {
                //build object to send to the API
                var bookInfo = new BookHearingInfo
                {
                    CEIS_Physical_File_ID = bookingInfo.CaseId,
                    containerID           = bookingInfo.ContainerId,
                    dateTime      = model.FullDate,
                    hearingLength = bookingInfo.HearingLengthMinutes,
                    locationID    = bookingInfo.BookingRegistryId,
                    requestedBy   = $"{userDisplayName} {model.Phone} {model.EmailAddress}",
                    hearingTypeId = bookingInfo.HearingTypeId
                };

                //submit booking
                BookingHearingResult result = await _client.BookingHearingAsync(bookInfo);

                //get the raw result
                bookingInfo.RawResult = result.bookingResult;

                //test to see if the booking was successful
                if (result.bookingResult.ToLower().StartsWith("success"))
                {
                    //create database entry
                    DbSet <BookingHistory> bookingHistory = _dbContext.Set <BookingHistory>();

                    bookingHistory.Add(new BookingHistory
                    {
                        ContainerId   = bookingInfo.ContainerId,
                        SmGovUserGuid = userGuid,
                        Timestamp     = DateTime.Now
                    });

                    //save to DB
                    await _dbContext.SaveChangesAsync();

                    //update model
                    model.IsBooked       = true;
                    bookingInfo.IsBooked = true;

                    //store user info in session for next booking
                    var userInfo = new SessionUserInfo
                    {
                        Phone       = model.Phone,
                        Email       = model.EmailAddress,
                        ContactName = $"{userDisplayName}"
                    };

                    _session.UserInfo = userInfo;

                    var emailBody = await GetEmailBody();

                    //send email
                    await _mailService.SendEmail(
                        //"*****@*****.**",
                        model.EmailAddress,
                        EmailSubject,
                        emailBody);

                    //clear booking info session
                    _session.ScBookingInfo = null;
                }
                else
                {
                    model.IsBooked       = false;
                    bookingInfo.IsBooked = false;
                }
            }
            else
            {
                //The booking is not available anymore
                //user needs to choose a new time slot
                model.IsTimeSlotAvailable = false;
                model.IsBooked            = false;
                bookingInfo.IsBooked      = false;
            }

            // save the booking info back to the session
            _session.ScBookingInfo = bookingInfo;

            return(model);
        }
Esempio n. 5
0
        /// <summary>
        ///     Book court case
        /// </summary>
        public async Task <CoaCaseConfirmViewModel> BookCourtCase(CoaCaseConfirmViewModel model,
                                                                  string userGuid, string userDisplayName)
        {
            //if the user could not be detected return
            if (string.IsNullOrWhiteSpace(userGuid))
            {
                return(model);
            }

            CoaSessionBookingInfo bookingInfo = _session.CoaBookingInfo;

            // check the schedule again to make sure the time slot wasn't taken by someone else
            CoAAvailableDates schedule = await _client.COAAvailableDatesAsync();

            //ensure time slot is still available
            if (IsTimeStillAvailable(schedule, bookingInfo.SelectedDate.Value))
            {
                //Fetch final main case file after ruling out selection of cases with main case and related cases
                var finalCase    = bookingInfo.CaseList.Where(x => x.Case_Num == bookingInfo.CaseNumber).First();
                var relatedCases = "";
                if (finalCase.Main && model.RelatedCaseList != null && model.RelatedCaseList.Count > 0)
                {
                    var relatedCaseIDList = bookingInfo.CaseList.Where(x => model.RelatedCaseList.Contains(x.Case_Num)).Select(x => x.CaseId).ToList();
                    relatedCases = string.Join("|", relatedCaseIDList);
                }

                //build object to send to the API
                var bookInfo = new CoABookingHearingInfo
                {
                    caseID        = finalCase.CaseId,
                    MainCase      = finalCase.Main,
                    RelatedCases  = relatedCases,
                    email         = $"{model.EmailAddress}",
                    hearingDate   = DateTime.Parse($"{model.SelectedDate.Value}"),
                    hearingLength = (bookingInfo.IsFullDay ?? false) ? "Full" : "Half",
                    phone         = $"{model.Phone}",
                    hearingTypeId = bookingInfo.HearingTypeId,
                    requestedBy   = $"{userDisplayName}"
                };

                //submit booking
                BookingHearingResult result = await _client.CoAQueueHearingAsync(bookInfo);

                //get the raw result
                bookingInfo.RawResult = result.bookingResult;

                //test to see if the booking was successful
                if (result.bookingResult.ToLower().StartsWith("success"))
                {
                    //create database entry
                    DbSet <BookingHistory> bookingHistory = _dbContext.Set <BookingHistory>();

                    bookingHistory.Add(new BookingHistory
                    {
                        ContainerId   = bookingInfo.ContainerId,
                        SmGovUserGuid = userGuid,
                        Timestamp     = DateTime.Now
                    });

                    //save to DB
                    _dbContext.SaveChanges();

                    //update model
                    model.IsBooked       = true;
                    bookingInfo.IsBooked = true;

                    //store user info in session for next booking
                    var userInfo = new SessionUserInfo
                    {
                        Phone       = model.Phone,
                        Email       = model.EmailAddress,
                        ContactName = $"{userDisplayName}"
                    };

                    _session.UserInfo = userInfo;

                    //send email
                    await _mailService.SendEmail(
                        model.EmailAddress,
                        EmailSubject,
                        await GetEmailBody());

                    //clear booking info session
                    _session.CoaBookingInfo = null;
                }
                else
                {
                    model.IsBooked       = false;
                    bookingInfo.IsBooked = false;
                }
            }
            else
            {
                //The booking is not available anymore
                //user needs to choose a new time slot
                model.IsTimeSlotAvailable = false;
                model.IsBooked            = false;
                bookingInfo.IsBooked      = false;
            }

            // save the booking info back to the session
            _session.CoaBookingInfo = bookingInfo;

            return(model);
        }