public async Task <IActionResult> AddVenueManualAddress(string Id)
        {
            var viewModel = new VenueAddressSelectionConfirmationViewModel();

            if (Id != null)
            {
                GetVenueByIdCriteria criteria = new GetVenueByIdCriteria(Id);

                var getVenueByIdResult = await _venueService.GetVenueByIdAsync(criteria);

                if (getVenueByIdResult.IsSuccess)
                {
                    viewModel.Id        = Id;
                    viewModel.VenueName = getVenueByIdResult.Value.VenueName;
                    viewModel.Address   = new AddressModel
                    {
                        AddressLine1 = getVenueByIdResult.Value.Address1,
                        AddressLine2 = getVenueByIdResult.Value.Address2,
                        TownOrCity   = getVenueByIdResult.Value.Town,
                        County       = getVenueByIdResult.Value.County,
                        Postcode     = getVenueByIdResult.Value.PostCode
                    };
                }
                else
                {
                    viewModel.Error = getVenueByIdResult.Error;
                }
            }

            viewModel.Id = Id;

            return(View(viewModel));
        }
示例#2
0
        public static async Task <Dictionary <Guid, string> > GetVenueNames(IEnumerable <Course> courses, IVenueService venueService)
        {
            Dictionary <Guid, string> venueNames = new Dictionary <Guid, string>();

            foreach (var course in courses)
            {
                foreach (var courseRun in course.CourseRuns)
                {
                    if (courseRun.VenueId != Guid.Empty && courseRun.VenueId != null)
                    {
                        if (!venueNames.ContainsKey((Guid)courseRun.VenueId))
                        {
                            var result = await venueService.GetVenueByIdAsync(new GetVenueByIdCriteria(courseRun.VenueId.ToString()));

                            if (result.IsSuccess)
                            {
                                Guid.TryParse(result.Value.ID, out Guid venueId);
                                venueNames.Add(venueId, result.Value.VenueName);
                            }
                        }
                    }
                }
            }
            return(venueNames);
        }
        public async Task <IActionResult> GetVenueByIdAsync(Guid id)
        {
            VenueInventoryViewModel selectedVenue = await _venueService.GetVenueByIdAsync(id);

            if (selectedVenue == null)
            {
                return(NotFound(new { message = "No such venue found" }));
            }

            return(Ok(selectedVenue));
        }
        public ActionResult AddCombined(AddDeliveryOptionsCombinedModel model)
        {
            var apprenticeship = _session.GetObject <Apprenticeship>("selectedApprenticeship");

            if (model.LocationId.HasValue)
            {
                var venue = _venueService.GetVenueByIdAsync(
                    new GetVenueByIdCriteria(model.LocationId.Value.ToString()));

                string deliveryMethod = string.Empty;

                if (model.BlockRelease && model.DayRelease)
                {
                    deliveryMethod = "Employer address, Day release, Block release";
                }
                else
                {
                    deliveryMethod = model.DayRelease
                        ? "Employer address, Day release"
                        : "Employer address, Block release";
                }

                apprenticeship.ApprenticeshipLocations.Add(CreateDeliveryLocation(new DeliveryOption()
                {
                    Delivery     = deliveryMethod,
                    LocationId   = venue.Result.Value.ID.ToString(),
                    LocationName = venue.Result.Value.VenueName,
                    PostCode     = venue.Result.Value.PostCode,
                    Radius       = model.Radius,
                    National     = model.National,
                    Venue        = (Venue)venue.Result.Value
                }, ApprenticeshipLocationType.ClassroomBasedAndEmployerBased));

                _session.SetObject("selectedApprenticeship", apprenticeship);

                return(RedirectToAction("DeliveryOptionsCombined", "Apprenticeships"));
            }

            return(RedirectToAction("Summary", "Apprenticeships"));
        }
示例#5
0
        public IActionResult DeleteLocation(Guid VenueId)
        {
            int?UKPRN = Session.GetInt32("UKPRN");

            if (!UKPRN.HasValue)
            {
                return(RedirectToAction("Index", "Home", new { errmsg = "Please select a Provider." }));
            }

            var venueResult = _venueService
                              .GetVenueByIdAsync(new GetVenueByIdCriteria(VenueId.ToString())).Result
                              .Value;

            LocationDeleteViewModel locationDeleteViewModel = new LocationDeleteViewModel();

            locationDeleteViewModel.VenueId      = VenueId;
            locationDeleteViewModel.VenueName    = venueResult.VenueName;
            locationDeleteViewModel.PostCode     = venueResult.PostCode;
            locationDeleteViewModel.AddressLine1 = venueResult.Address1;

            return(View("../Venues/locationdelete/index", locationDeleteViewModel));
        }
示例#6
0
        internal CsvApprenticeship MapCsvApprenticeship(Apprenticeship apprenticeship, ApprenticeshipLocation location)
        {
            SelectRegionModel selectRegionModel = new SelectRegionModel();

            return(new CsvApprenticeship
            {
                StandardCode = apprenticeship.StandardCode?.ToString(),
                Version = apprenticeship.Version?.ToString(),
                FrameworkCode = apprenticeship.FrameworkCode?.ToString(),
                ProgType = apprenticeship.ProgType?.ToString(),
                PathwayCode = apprenticeship.PathwayCode?.ToString(),
                ApprenticeshipInformation = _CSVHelper.SanitiseTextForCSVOutput(apprenticeship.MarketingInformation),
                ApprenticeshipWebpage = apprenticeship.Url,
                ContactEmail = apprenticeship.ContactEmail,
                ContactPhone = apprenticeship.ContactTelephone,
                ContactURL = apprenticeship.ContactWebsite,
                DeliveryMethod = DeliveryMethodConvert(location.ApprenticeshipLocationType),
                Venue = location.VenueId.HasValue ? _venueService.GetVenueByIdAsync(new GetVenueByIdCriteria
                                                                                        (location.VenueId.Value.ToString())).Result.Value?.VenueName : String.Empty,
                Radius = location.Radius?.ToString(),
                DeliveryMode = DeliveryModeConvert(location.DeliveryModes),
                AcrossEngland = location.ApprenticeshipLocationType == ApprenticeshipLocationType.ClassroomBasedAndEmployerBased ?
                                AcrossEnglandConvert(location.Radius, location.National) :
                                String.Empty,
                NationalDelivery = location.ApprenticeshipLocationType == ApprenticeshipLocationType.EmployerBased ?  BoolConvert(location.National) : string.Empty,
                Region = location.Regions != null?_CSVHelper.SemiColonSplit(
                    selectRegionModel.RegionItems
                    .Where(x => location.Regions.Contains(x.Id))
                    .Select(y => _CSVHelper.SanitiseTextForCSVOutput(y.RegionName).Replace(",", "")).ToList())
                             : string.Empty,
                             Subregion = location.Regions != null?_CSVHelper.SemiColonSplit(
                                 selectRegionModel.RegionItems.SelectMany(
                                     x => x.SubRegion.Where(
                                         y => location.Regions.Contains(y.Id)).Select(
                                         z => _CSVHelper.SanitiseTextForCSVOutput(z.SubRegionName).Replace(",", "")).ToList())) : string.Empty,
            });
        }
示例#7
0
        public IActionResult Index(Guid?courseId, Guid?courseRunId)
        {
            Course    course    = null;
            CourseRun courseRun = null;

            if (courseId.HasValue)
            {
                course    = _courseService.GetCourseByIdAsync(new GetCourseByIdCriteria(courseId.Value)).Result.Value;
                courseRun = course.CourseRuns.Where(x => x.id == courseRunId.Value).FirstOrDefault();
            }

            CourseSummaryViewModel vm = new CourseSummaryViewModel

            {
                ProviderUKPRN            = course.ProviderUKPRN,
                CourseId                 = course.id,
                QualificationCourseTitle = course.QualificationCourseTitle,
                LearnAimRef              = course.LearnAimRef,
                NotionalNVQLevelv2       = course.NotionalNVQLevelv2,
                AwardOrgCode             = course.AwardOrgCode,
                CourseDescription        = course.CourseDescription,
                EntryRequirements        = course.EntryRequirements,
                WhatYoullLearn           = course.WhatYoullLearn,
                HowYoullLearn            = course.HowYoullLearn,
                WhatYoullNeed            = course.WhatYoullNeed,
                HowYoullBeAssessed       = course.HowYoullBeAssessed,
                WhereNext                = course.WhereNext,
                IsValid           = course.IsValid,
                QualificationType = course.QualificationType,

                //Course run deets
                CourseInstanceId = courseRunId,
                CourseName       = courseRun.CourseName,
                VenueId          = courseRun.VenueId,
                Cost             = courseRun.Cost,
                CostDescription  = courseRun.CostDescription,
                DurationUnit     = courseRun.DurationUnit,
                DurationValue    = courseRun.DurationValue,
                ProviderCourseID = courseRun.ProviderCourseID,
                DeliveryMode     = courseRun.DeliveryMode,
                National         = courseRun.DeliveryMode == DeliveryMode.WorkBased & !courseRun.National.HasValue ||
                                   courseRun.National.GetValueOrDefault(),
                FlexibleStartDate = courseRun.FlexibleStartDate,
                StartDate         = courseRun.StartDate,
                StudyMode         = courseRun.StudyMode,
                AttendancePattern = courseRun.AttendancePattern,
                CreatedBy         = courseRun.CreatedBy,
                CreatedDate       = courseRun.CreatedDate,
            };

            //Determine newer edited date
            if (course.UpdatedDate > courseRun.UpdatedDate)
            {
                vm.UpdatedDate = course.UpdatedDate;
                vm.UpdatedBy   = course.UpdatedBy;
            }
            else
            {
                vm.UpdatedDate = courseRun.UpdatedDate;
                vm.UpdatedBy   = courseRun.UpdatedBy;
            }

            if (vm.VenueId != null)
            {
                if (vm.VenueId != Guid.Empty)
                {
                    vm.VenueName = _venueService
                                   .GetVenueByIdAsync(new GetVenueByIdCriteria(courseRun.VenueId.Value.ToString())).Result.Value
                                   .VenueName;
                }
            }

            if (!string.IsNullOrEmpty(courseRun.CourseURL))
            {
                if (courseRun.CourseURL.Contains("http") || courseRun.CourseURL.Contains("https"))
                {
                    vm.CourseURL = courseRun.CourseURL;
                }
                else
                {
                    vm.CourseURL = "http://" + courseRun.CourseURL;
                }
            }

            if (courseRun.Regions != null)
            {
                var allRegions = _courseService.GetRegions().RegionItems;
                var regions    = GetRegions().RegionItems.Select(x => x.Id);
                vm.Regions = FormattedRegionsByIds(allRegions, courseRun.Regions);
            }
            return(View(vm));
        }
示例#8
0
        internal IEnumerable <CsvCourse> CoursesToCsvCourses(IEnumerable <Course> courses)
        {
            List <CsvCourse> csvCourses = new List <CsvCourse>();

            foreach (var course in courses)
            {
                //First course run is on same line as course line in CSV
                var firstCourseRun = course.CourseRuns.First();

                if (firstCourseRun.Regions != null)
                {
                    firstCourseRun.Regions = _CSVHelper.SanitiseRegionTextForCSVOutput(firstCourseRun.Regions);
                }

                SelectRegionModel selectRegionModel = new SelectRegionModel();

                CsvCourse csvCourse = new CsvCourse
                {
                    LearnAimRef = course.LearnAimRef != null?_CSVHelper.SanitiseTextForCSVOutput(course.LearnAimRef) : string.Empty,
                                      CourseDescription    = !string.IsNullOrWhiteSpace(course.CourseDescription) ? _CSVHelper.SanitiseTextForCSVOutput(course.CourseDescription) : string.Empty,
                                      EntryRequirements    = !string.IsNullOrWhiteSpace(course.EntryRequirements) ? _CSVHelper.SanitiseTextForCSVOutput(course.EntryRequirements) : string.Empty,
                                      WhatYoullLearn       = !string.IsNullOrWhiteSpace(course.WhatYoullLearn) ? _CSVHelper.SanitiseTextForCSVOutput(course.WhatYoullLearn) : string.Empty,
                                      HowYoullLearn        = !string.IsNullOrWhiteSpace(course.HowYoullLearn) ? _CSVHelper.SanitiseTextForCSVOutput(course.HowYoullLearn) : string.Empty,
                                      WhatYoullNeed        = !string.IsNullOrWhiteSpace(course.WhatYoullNeed) ? _CSVHelper.SanitiseTextForCSVOutput(course.WhatYoullNeed) : string.Empty,
                                      HowYoullBeAssessed   = !string.IsNullOrWhiteSpace(course.HowYoullBeAssessed) ? _CSVHelper.SanitiseTextForCSVOutput(course.HowYoullBeAssessed) : string.Empty,
                                      WhereNext            = !string.IsNullOrWhiteSpace(course.WhereNext) ? _CSVHelper.SanitiseTextForCSVOutput(course.WhereNext) : string.Empty,
                                      AdvancedLearnerLoan  = course.AdvancedLearnerLoan ? "Yes" : "No",
                                      AdultEducationBudget = course.AdultEducationBudget ? "Yes" : "No",
                                      CourseName           = firstCourseRun.CourseName != null?_CSVHelper.SanitiseTextForCSVOutput(firstCourseRun.CourseName) : string.Empty,
                                                                 ProviderCourseID = firstCourseRun.ProviderCourseID != null?_CSVHelper.SanitiseTextForCSVOutput(firstCourseRun.ProviderCourseID) : string.Empty,
                                                                                        DeliveryMode      = firstCourseRun.DeliveryMode.ToDescription(),
                                                                                        StartDate         = firstCourseRun.StartDate.HasValue ? firstCourseRun.StartDate.Value.ToString("dd/MM/yyyy") : string.Empty,
                                                                                        FlexibleStartDate = firstCourseRun.FlexibleStartDate ? "Yes" : string.Empty,
                                                                                        National          = firstCourseRun.National.HasValue ? (firstCourseRun.National.Value ? "Yes" : "No") : string.Empty,
                                                                                        Regions           = firstCourseRun.Regions != null?_CSVHelper.SemiColonSplit(
                                                                                            selectRegionModel.RegionItems
                                                                                            .Where(x => firstCourseRun.Regions.Contains(x.Id))
                                                                                            .Select(y => _CSVHelper.SanitiseTextForCSVOutput(y.RegionName).Replace(",", "")).ToList())
                                                                                                                : string.Empty,
                                                                                                                SubRegions = firstCourseRun.Regions != null?_CSVHelper.SemiColonSplit(
                                                                                                                    selectRegionModel.RegionItems.SelectMany(
                                                                                                                        x => x.SubRegion.Where(
                                                                                                                            y => firstCourseRun.Regions.Contains(y.Id)).Select(
                                                                                                                            z => _CSVHelper.SanitiseTextForCSVOutput(z.SubRegionName).Replace(",", "")).ToList())) : string.Empty,
                                                                                                                                 CourseURL                                             = firstCourseRun.CourseURL != null?_CSVHelper.SanitiseTextForCSVOutput(firstCourseRun.CourseURL) : string.Empty,
                                                                                                                                                                       Cost            = firstCourseRun.Cost.HasValue ? firstCourseRun.Cost.Value.ToString() : string.Empty,
                                                                                                                                                                       CostDescription = firstCourseRun.CostDescription != null?_CSVHelper.SanitiseTextForCSVOutput(firstCourseRun.CostDescription) : string.Empty,
                                                                                                                                                                                             DurationValue     = firstCourseRun.DurationValue.HasValue ? firstCourseRun.DurationValue.Value.ToString() : string.Empty,
                                                                                                                                                                                             DurationUnit      = firstCourseRun.DurationUnit.ToDescription(),
                                                                                                                                                                                             StudyMode         = firstCourseRun.StudyMode.ToDescription(),
                                                                                                                                                                                             AttendancePattern = firstCourseRun.AttendancePattern.ToDescription()
                };
                if (firstCourseRun.VenueId.HasValue)
                {
                    var result = _venueService.GetVenueByIdAsync(new GetVenueByIdCriteria(firstCourseRun.VenueId.Value.ToString())).Result;

                    if (result.IsSuccess && !string.IsNullOrWhiteSpace(result.Value.VenueName))
                    {
                        csvCourse.VenueName = result.Value.VenueName;
                    }
                }
                csvCourses.Add(csvCourse);
                foreach (var courseRun in course.CourseRuns)
                {
                    //Ignore the first course run as we've already captured it
                    if (courseRun.id == firstCourseRun.id)
                    {
                        continue;
                    }

                    //Sanitise regions
                    if (courseRun.Regions != null)
                    {
                        courseRun.Regions = _CSVHelper.SanitiseRegionTextForCSVOutput(courseRun.Regions);
                    }

                    CsvCourse csvCourseRun = new CsvCourse
                    {
                        LearnAimRef = course.LearnAimRef != null?_CSVHelper.SanitiseTextForCSVOutput(course.LearnAimRef) : string.Empty,
                                          CourseName = courseRun.CourseName != null?_CSVHelper.SanitiseTextForCSVOutput(courseRun.CourseName) : string.Empty,
                                                           ProviderCourseID = courseRun.ProviderCourseID != null?_CSVHelper.SanitiseTextForCSVOutput(courseRun.ProviderCourseID) : string.Empty,
                                                                                  DeliveryMode      = courseRun.DeliveryMode.ToDescription(),
                                                                                  StartDate         = courseRun.StartDate.HasValue ? courseRun.StartDate.Value.ToString("dd/MM/yyyy") : string.Empty,
                                                                                  FlexibleStartDate = courseRun.FlexibleStartDate ? "Yes" : string.Empty,
                                                                                  National          = courseRun.National.HasValue ? (courseRun.National.Value ? "Yes" : "No") : string.Empty,
                                                                                  Regions           = courseRun.Regions != null?_CSVHelper.SemiColonSplit(
                                                                                      selectRegionModel.RegionItems
                                                                                      .Where(x => courseRun.Regions.Contains(x.Id))
                                                                                      .Select(y => _CSVHelper.SanitiseTextForCSVOutput(y.RegionName).Replace(",", "")).ToList())
                                                                                                          : string.Empty,
                                                                                                          SubRegions = courseRun.Regions != null?_CSVHelper.SemiColonSplit(
                                                                                                              selectRegionModel.RegionItems.SelectMany(
                                                                                                                  x => x.SubRegion.Where(
                                                                                                                      y => courseRun.Regions.Contains(y.Id)).Select(
                                                                                                                      z => _CSVHelper.SanitiseTextForCSVOutput(z.SubRegionName).Replace(",", "")).ToList())) : string.Empty,
                                                                                                                           CourseURL                                             = courseRun.CourseURL != null?_CSVHelper.SanitiseTextForCSVOutput(courseRun.CourseURL) : string.Empty,
                                                                                                                                                                 Cost            = courseRun.Cost.HasValue ? courseRun.Cost.Value.ToString() : string.Empty,
                                                                                                                                                                 CostDescription = courseRun.CostDescription != null?_CSVHelper.SanitiseTextForCSVOutput(courseRun.CostDescription) : string.Empty,
                                                                                                                                                                                       DurationValue     = courseRun.DurationValue.HasValue ? courseRun.DurationValue.Value.ToString() : string.Empty,
                                                                                                                                                                                       DurationUnit      = courseRun.DurationUnit.ToDescription(),
                                                                                                                                                                                       StudyMode         = courseRun.StudyMode.ToDescription(),
                                                                                                                                                                                       AttendancePattern = courseRun.AttendancePattern.ToDescription()
                    };

                    if (courseRun.VenueId.HasValue)
                    {
                        var result = _venueService.GetVenueByIdAsync(new GetVenueByIdCriteria
                                                                         (courseRun.VenueId.Value.ToString())).Result;

                        if (result.IsSuccess && !string.IsNullOrWhiteSpace(result.Value.VenueName))
                        {
                            csvCourseRun.VenueName = result.Value.VenueName;
                        }
                    }
                    csvCourses.Add(csvCourseRun);
                }
            }
            return(csvCourses);
        }
示例#9
0
        public async Task <IActionResult> AddBookingAsync([FromBody] BookingModelDTO BookingModelDTO)
        {
            Guard.Against.Null(BookingModelDTO, nameof(BookingModelDTO));

            bool refCodeDiscount = false;

            if (!string.IsNullOrEmpty(BookingModelDTO.ReferralCode))
            {
                (bool HasReferralCodeTransactionCountExceeded, bool IsDuplicateTransaction, bool IsReferralCodeSelfUsed) = await _bookingManager.CheckReferralCodeAsync(BookingModelDTO.ReferralCode, Guid.Parse(BookingModelDTO.UserID));

                if (HasReferralCodeTransactionCountExceeded)
                {
                    return(BadRequest(new { message = "Referral Code provided cannot be used, as it has been used 3 times." }));
                }
                if (IsDuplicateTransaction)
                {
                    return(BadRequest(new { message = "Referral Code shared to you cannot be used more than once, please apply with a fresh one." }));
                }
                if (IsReferralCodeSelfUsed)
                {
                    return(BadRequest(new { message = "Referral Code provider and the beneficiary cannot be same!" }));
                }

                refCodeDiscount = true;
            }

            DateTime bookingFromDate = DateTime.Parse(BookingModelDTO.BookedFrom, CultureInfo.InvariantCulture, DateTimeStyles.RoundtripKind);
            DateTime bookingToDate   = DateTime.Parse(BookingModelDTO.BookedTo, CultureInfo.InvariantCulture, DateTimeStyles.RoundtripKind);

            bool availabilityOfVenue = await _bookingManager.CheckBookingAvailabilityAsync(bookingFromDate, bookingToDate, BookingModelDTO.VenueID);

            if (!availabilityOfVenue)
            {
                return(BadRequest(new { message = "Sorry, try to book for some other slot, the current selected slot is already booked by someone else." }));
            }

            Guid     bookingId       = Guid.NewGuid();
            TimeSpan bookingTimeSpan = (bookingToDate - bookingFromDate);

            VenueInventoryViewModel selectedVenueDetail = await _venueService.GetVenueByIdAsync(BookingModelDTO.VenueID);

            double calculatedPrice = bookingTimeSpan.TotalHours * selectedVenueDetail.HourlyRate;

            if (refCodeDiscount)
            {
                calculatedPrice = calculatedPrice - (0.1 * calculatedPrice);
            }
            //Entity Model
            Booking newBooking = new Booking
            {
                BookingID       = bookingId,
                VenueID         = BookingModelDTO.VenueID,
                BookingFromDate = bookingFromDate,
                BookingToDate   = bookingToDate,
                UserID          = Guid.Parse(BookingModelDTO.UserID),
                Price           = calculatedPrice,
                BookingStatus   = BookingStatus.ACTIVE.ToString()
            };

            await _bookingManager.AddNewBookingAsync(newBooking, BookingModelDTO.ReferralCode, BookingModelDTO.TimeZoneId);

            return(StatusCode(201, new { message = $"Successfully booked the venue {selectedVenueDetail.VenueName}." }));
        }