Exemple #1
0
        public async Task <List <int> > GetConferenceTypeIds(ScCaseSearchViewModel model)
        {
            //set selected registry name
            model.CaseLocationName = await _cache.GetLocationNameAsync(model.CaseRegistryId);

            return(await GetConferenceTypesAsync(model.CaseLocationName));
        }
Exemple #2
0
        public async Task <IActionResult> Index(ScCaseSearchViewModel model)
        {
            if (model.CaseRegistryId == -1)
            {
                ModelState.AddModelError("CaseRegistryId", "Please select the registry where the file was created");
            }

            if (string.IsNullOrWhiteSpace(model.CaseNumber))
            {
                ModelState.AddModelError("CaseNumber", "Please provide a Court File Number");
            }

            // ToDo: the following check is just for testing and will be removed later
            if (model.CaseRegistryId != 6)
            {
                model.AvailableConferenceTypeIds = await _scBookingService.GetConferenceTypeIds(model);
            }
            else
            {
                model.AvailableConferenceTypeIds = null;
            }

            if (!ModelState.IsValid)
            {
                return(View(model));
            }

            model = await _scBookingService.GetSearchResults2(model);

            return(View(model));
        }
Exemple #3
0
        public async Task <IActionResult> ConferenceType(ScCaseSearchViewModel model)
        {
            if (model.HearingTypeId == -1)
            {
                ModelState.AddModelError("HearingTypeId", "Please choose a conference type.");
            }

            if (!ModelState.IsValid)
            {
                return(View(model));
            }

            await _scBookingService.SaveScBookingInfoAsync(model);

            return(RedirectToAction("AvailableTimes"));
        }
Exemple #4
0
        public async Task <IActionResult> CaseSelectedAsync(ScCaseSearchViewModel model)
        {
            model.IsConfirmingCase = true;

            if (model.SelectedCaseId == 0)
            {
                ModelState.AddModelError("SelectedCaseId", "Please choose a case.");
            }

            if (!ModelState.IsValid)
            {
                return(View("Index", model));
            }

            await _scBookingService.SaveScBookingInfoAsync(model);

            return(RedirectToAction("ConferenceType"));
        }
Exemple #5
0
        public async Task <IActionResult> CaseSearch(ScCaseSearchViewModel model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }

            model = await _scBookingService.GetSearchResults(model);

            //test if the user selected a time-slot that is available
            if (model != null && model.ContainerId > 0 && !model.TimeSlotExpired)
            //go to confirmation screen
            {
                return(new RedirectResult("/scjob/booking/sc/CaseConfirm"));
            }

            return(View(model));
        }
Exemple #6
0
        public async Task <IActionResult> AvailableTimes(ScCaseSearchViewModel model)
        {
            model.Results = _session.ScBookingInfo.Results;

            if (model.ContainerId == -1)
            {
                ModelState.AddModelError("ContainerId", "Please choose from one of the available times.");
            }

            if (!ModelState.IsValid)
            {
                return(View(model));
            }

            await _scBookingService.SaveScBookingInfoAsync(model);

            return(RedirectToAction("CaseConfirm"));
        }
Exemple #7
0
        public async Task <ScCaseSearchViewModel> GetSearchResults2(ScCaseSearchViewModel model)
        {
            // Load locations from cache
            var result = new ScCaseSearchViewModel
            {
                CaseRegistryId             = model.CaseRegistryId,
                CaseNumber                 = model.CaseNumber,
                SelectedCourtClass         = model.SelectedCourtClass,
                CaseLocationName           = model.CaseLocationName,
                AvailableConferenceTypeIds = model.AvailableConferenceTypeIds,
            };

            //search the current case number
            (result.FullCaseNumber, result.LocationPrefix) = await BuildCaseNumber(model.CaseNumber, model.CaseRegistryId);

            result.CourtFiles = await _client.caseNumberValidAsync(result.FullCaseNumber);

            if (!result.IsValidCaseNumber)
            {
                //get contact information
                result.RegistryContactNumber = GetRegistryContactNumber(model.CaseRegistryId);
            }
            else
            {
                _session.ScBookingInfo = new ScSessionBookingInfo
                {
                    CaseNumber       = model.CaseNumber.ToUpper().Trim(),
                    FullCaseNumber   = result.FullCaseNumber,
                    LocationPrefix   = result.LocationPrefix,
                    CourtFiles       = result.CourtFiles,
                    CaseRegistryId   = model.CaseRegistryId,
                    CaseLocationName = result.CaseLocationName,
                };
            }

            return(result);
        }
Exemple #8
0
        public async Task SaveScBookingInfoAsync(ScCaseSearchViewModel model)
        {
            var bookingInfo = _session.ScBookingInfo;

            if (bookingInfo.CaseId != model.SelectedCaseId)
            {
                bookingInfo.CaseId = model.SelectedCaseId;
            }

            if (!string.IsNullOrWhiteSpace(model.SelectedCourtClass) &&
                bookingInfo.SelectedCourtClass != model.SelectedCourtClass)
            {
                bookingInfo.SelectedCourtClass = model.SelectedCourtClass;
            }

            if (!string.IsNullOrWhiteSpace(model.FileNumber) &&
                bookingInfo.FileNumber != model.FileNumber)
            {
                bookingInfo.FileNumber = model.FileNumber;
            }

            if (bookingInfo.SelectedCourtClassName != model.SelectedCourtClassName)
            {
                bookingInfo.SelectedCourtClassName = model.SelectedCourtClassName;
            }

            bookingInfo.SelectedCourtFile          = model.SelectedCourtFile;
            bookingInfo.AvailableConferenceTypeIds = model.AvailableConferenceTypeIds;

            //set hearing type name
            if (model.HearingTypeId > 0 &&
                ScHearingType.HearingTypeNameMap.ContainsKey(model.HearingTypeId) &&
                bookingInfo.HearingTypeId != model.HearingTypeId)
            {
                bookingInfo.HearingTypeId   = model.HearingTypeId;
                bookingInfo.HearingTypeName = ScHearingType.HearingTypeNameMap[model.HearingTypeId];

                bookingInfo.BookingRegistryId = await _cache.GetBookingLocationIdAsync(
                    bookingInfo.CaseRegistryId,
                    bookingInfo.HearingTypeId
                    ) ?? bookingInfo.CaseRegistryId;

                bookingInfo.BookingLocationName = await _cache.GetLocationNameAsync(
                    bookingInfo.BookingRegistryId);

                bookingInfo.Results = await _client.AvailableDatesByLocationAsync(
                    bookingInfo.BookingRegistryId,
                    bookingInfo.HearingTypeId);
            }

            if (model.ContainerId > 0)
            {
                if (!string.IsNullOrWhiteSpace(model.SelectedCaseDate) &&
                    bookingInfo.SelectedCaseDate != model.SelectedCaseDate)
                {
                    bookingInfo.SelectedCaseDate = model.SelectedCaseDate;
                }

                model.TimeSlotExpired = !IsTimeStillAvailable(bookingInfo.Results, model.ContainerId);

                if (bookingInfo.ContainerId != model.ContainerId)
                {
                    bookingInfo.ContainerId = model.ContainerId;
                }

                if (bookingInfo.FullDate != model.FullDate)
                {
                    bookingInfo.FullDate = model.FullDate;
                }
            }

            _session.ScBookingInfo = bookingInfo;
        }
Exemple #9
0
        /// <summary>
        ///     Search for available times
        /// </summary>
        public async Task <ScCaseSearchViewModel> GetSearchResults(ScCaseSearchViewModel model)
        {
            // Load locations from cache
            var retval = new ScCaseSearchViewModel
            {
                HearingTypeId      = model.HearingTypeId,
                CaseRegistryId     = model.CaseRegistryId,
                CaseNumber         = model.CaseNumber,
                TimeSlotExpired    = model.TimeSlotExpired,
                SelectedCourtClass = model.SelectedCourtClass
            };

            //set hearing type name
            if (retval.HearingTypeId > 0 && ScHearingType.HearingTypeNameMap.ContainsKey(retval.HearingTypeId))
            {
                retval.HearingTypeName = ScHearingType.HearingTypeNameMap[retval.HearingTypeId];
            }

            //set selected registry name
            retval.CaseLocationName = await _cache.GetLocationNameAsync(retval.CaseRegistryId);

            // set booking location information
            retval.BookingRegistryId = await _cache.GetBookingLocationIdAsync(
                retval.CaseRegistryId,
                retval.HearingTypeId
                ) ?? retval.CaseRegistryId;

            retval.BookingLocationName = await _cache.GetLocationNameAsync(retval.BookingRegistryId);

            //search the current case number
            (retval.FullCaseNumber, retval.LocationPrefix) = await BuildCaseNumber(model.CaseNumber, model.CaseRegistryId);

            retval.CourtFiles = await _client.caseNumberValidAsync(retval.FullCaseNumber);

            if (!retval.IsValidCaseNumber)
            {
                //get contact information
                retval.RegistryContactNumber = GetRegistryContactNumber(model.CaseRegistryId);
            }
            else
            {
                retval.Results = await _client.AvailableDatesByLocationAsync(
                    retval.BookingRegistryId,
                    model.HearingTypeId
                    );

                //check for valid date
                if (model.ContainerId > 0)
                {
                    retval.TimeSlotExpired = !IsTimeStillAvailable(retval.Results, model.ContainerId);

                    //convert JS ticks to .Net date
                    DateTime?dt = new DateTime(Convert.ToInt64(model.SelectedCaseDate));

                    //set date properties
                    retval.ContainerId      = model.ContainerId;
                    retval.SelectedCaseDate = model.SelectedCaseDate;

                    string bookingTime = $"{dt.Value:hh:mm tt} to {dt.Value.AddMinutes(retval.HearingLengthMinutes):hh:mm tt}";

                    retval.TimeSlotFriendlyName = $"{dt.Value:MMMM dd} from {bookingTime}";
                }

                _session.ScBookingInfo = new ScSessionBookingInfo
                {
                    ContainerId         = model.ContainerId,
                    CaseNumber          = model.CaseNumber.ToUpper().Trim(),
                    FullCaseNumber      = retval.FullCaseNumber,
                    CaseId              = (int)retval.CourtFiles[0].physicalFileId,
                    HearingTypeId       = model.HearingTypeId,
                    HearingTypeName     = retval.HearingTypeName,
                    Results             = retval.Results,
                    CaseRegistryId      = model.CaseRegistryId,
                    CaseLocationName    = retval.CaseLocationName,
                    BookingRegistryId   = retval.BookingRegistryId,
                    BookingLocationName = retval.BookingLocationName,
                    SelectedCaseDate    = model.SelectedCaseDate,
                };
            }

            return(retval);
        }
        /// <summary>
        ///     Search for available times
        /// </summary>
        public async Task <ScCaseSearchViewModel> GetSearchResults(ScCaseSearchViewModel model)
        {
            // Load locations from cache
            var retval = new ScCaseSearchViewModel
            {
                HearingTypeId      = model.HearingTypeId,
                CaseRegistryId     = model.CaseRegistryId,
                CaseNumber         = model.CaseNumber,
                TimeSlotExpired    = model.TimeSlotExpired,
                SelectedCourtClass = model.SelectedCourtClass
            };


            //set hearing type name
            if (retval.HearingTypeId > 0 && ScHearingType.HearingTypeNameMap.ContainsKey(retval.HearingTypeId))
            {
                retval.HearingTypeName = ScHearingType.HearingTypeNameMap[retval.HearingTypeId];
            }

            //set selected registry name
            retval.CaseLocationName = await _cache.GetLocationNameAsync(retval.CaseRegistryId);

            // set booking location information
            retval.BookingRegistryId = await _cache.GetBookingLocationIdAsync(
                retval.CaseRegistryId,
                retval.HearingTypeId
                ) ?? retval.CaseRegistryId;

            retval.BookingLocationName = await _cache.GetLocationNameAsync(retval.BookingRegistryId);

            //search the current case number
            string caseNumber = await BuildCaseNumber(model.CaseNumber, model.CaseRegistryId);

            int caseId = await _client.caseNumberValidAsync(caseNumber);

            if (caseId == 0)
            {
                //case could not be found
                retval.IsValidCaseNumber = false;

                //empty result set
                retval.Results = new AvailableDatesByLocation();

                //get contact information
                retval.RegistryContactNumber = GetRegistryContactNumber(model.CaseRegistryId);
            }
            else
            {
                //valid case number
                retval.IsValidCaseNumber = true;

                AvailableDatesByLocation schedule = await _client.AvailableDatesByLocationAsync(
                    retval.BookingRegistryId,
                    model.HearingTypeId
                    );

                int hearingLength = schedule.BookingDetails.detailBookingLength;

                retval.Results = schedule;
                string   bookingTime = "";
                DateTime?dt          = null;

                //check for valid date
                if (model.ContainerId > 0)
                {
                    if (!IsTimeStillAvailable(schedule, model.ContainerId))
                    {
                        retval.TimeSlotExpired = true;
                    }

                    //convert JS ticks to .Net date
                    dt = new DateTime(Convert.ToInt64(model.SelectedCaseDate));

                    //set date properties
                    retval.ContainerId      = model.ContainerId;
                    retval.SelectedCaseDate = model.SelectedCaseDate;

                    bookingTime = $"{dt.Value:hh:mm tt} to {dt.Value.AddMinutes(hearingLength):hh:mm tt}";

                    retval.TimeSlotFriendlyName = $"{dt.Value:MMMM dd} from {bookingTime}";
                }

                _session.ScBookingInfo = new ScSessionBookingInfo
                {
                    ContainerId          = model.ContainerId,
                    CaseNumber           = model.CaseNumber.ToUpper().Trim(),
                    FullCaseNumber       = caseNumber,
                    CaseId               = caseId,
                    HearingTypeId        = model.HearingTypeId,
                    HearingTypeName      = retval.HearingTypeName,
                    HearingLengthMinutes = hearingLength,
                    CaseRegistryId       = model.CaseRegistryId,
                    CaseLocationName     = retval.CaseLocationName,
                    BookingRegistryId    = retval.BookingRegistryId,
                    BookingLocationName  = retval.BookingLocationName,
                    TimeSlotFriendlyName = bookingTime,
                    SelectedCaseDate     = model.SelectedCaseDate,
                    DateFriendlyName     = dt?.ToString("dddd, MMMM dd, yyyy") ?? ""
                };
            }

            return(retval);
        }