public ActionResult VenueEdit(VenueEditVM vm) { if (ModelState.IsValid) { VenueInfo venueinfo = vm.venueinfo; //VenueFeature venuefeature = vm.venuefeature; db.Entry(vm.venueinfo).State = EntityState.Modified; db.SaveChanges(); foreach (var item in vm.venueaddress) { db.Entry(item).State = EntityState.Modified; } db.SaveChanges(); foreach (var item in vm.venuefeature) { db.Entry(item).State = EntityState.Modified; } db.SaveChanges(); } return(RedirectToAction("VenueList")); }
public static Venue ToVenue(this VenueInfo venueInfo) { double?distance = venueInfo.DistanceSpecified ? venueInfo.Distance : default(double?); return(new Venue( venueInfo.VenueName, venueInfo.VenueAddress.ToAddess(), string.Empty, //Not available in Venueinfo distance)); }
private async Task <Guid> GivenVenue() { var venueGuid = Guid.NewGuid(); var venueModel = new VenueInfo { VenueGuid = venueGuid }; await venueCommands.SaveVenue(venueModel); return(venueGuid); }
private static LocationDetails GetVenue(VenueInfo venueInfo) { if (venueInfo is null) { return(null); } var address = new Dictionary <string, string> { [nameof(VenueInfo.VenueAddress.Address_line_1)] = venueInfo.VenueAddress.Address_line_1, [nameof(VenueInfo.VenueAddress.Address_line_2)] = venueInfo.VenueAddress.Address_line_2, [nameof(VenueInfo.VenueAddress.Town)] = venueInfo.VenueAddress.Town, [nameof(VenueInfo.VenueAddress.PostCode)] = venueInfo.VenueAddress.PostCode }; return(new LocationDetails { Distance = venueInfo.Distance, LocationAddress = string.Join(", ", address.Where(x => !string.IsNullOrWhiteSpace(x.Value)).Select(add => add.Value)) }); }
public void TestAppealToTheEmptyVenue() { SendMessageResult sendMessage = mTelegramBot.SendMessage(mChatId, "TestAppealToTheEmptyLocation()"); VenueInfo venue = sendMessage.Result.Venue; ConsoleUtlis.PrintResult(venue); Assert.Multiple(() => { Assert.True(sendMessage.Ok); Assert.IsInstanceOf(typeof(VenueInfo), venue); Assert.AreEqual(0, venue.Location.Latitude); Assert.AreEqual(0, venue.Location.Longitude); Assert.IsNull(venue.Title); Assert.IsNull(venue.Address); Assert.IsNull(venue.FoursquareId); }); }
public async Task <ShowInfo> GetShow(Guid actGuid, Guid venueGuid, DateTimeOffset startTime) { var result = await repository.Show .Where(show => show.Act.ActGuid == actGuid && show.Venue.VenueGuid == venueGuid && show.StartTime == startTime && !show.Cancelled.Any()) .Select(show => new { VenueGuid = show.Venue.VenueGuid, VenueDescription = show.Venue.Descriptions .OrderByDescending(d => d.ModifiedDate) .FirstOrDefault() }) .SingleOrDefaultAsync(); return(result == null ? null : new ShowInfo { ActGuid = actGuid, Venue = VenueInfo.FromEntities(result.VenueGuid, result.VenueDescription), StartTime = startTime }); }
public async Task <List <ShowInfo> > ListShows(Guid actGuid) { var result = await repository.Show .Where(show => show.Act.ActGuid == actGuid && !show.Cancelled.Any()) .Select(show => new { VenueGuid = show.Venue.VenueGuid, VenueDescription = show.Venue.Descriptions .OrderByDescending(d => d.ModifiedDate) .FirstOrDefault(), StartTime = show.StartTime }) .ToListAsync(); return(result.Select(show => new ShowInfo { ActGuid = actGuid, Venue = VenueInfo.FromEntities(show.VenueGuid, show.VenueDescription), StartTime = show.StartTime }) .ToList()); }
public ActionResult Add(DashBoardViewModel model) { if (Session["User"] == null) { return(RedirectToAction("index", "User")); } int UserId = ((fyp_One.Models.User)Session["User"]).user_id; if (ModelState.IsValid) { VenueInfo venueinfo = new VenueInfo { verify = 1, venueName = model.venueName, venueType = model.venueType, capacity = Convert.ToInt32(model.capacity), venueWebsite = model.venueWebsite, venuePrice = Convert.ToInt32(model.venuePrice), user_id = UserId }; string[] features = model.venueFeature.Split(','); db.VenueInfoes.Add(venueinfo); db.SaveChanges(); foreach (var item in features) { if (item.Length > 0) { db.VenueFeatures.Add(new VenueFeature { Id_venueInfo = venueinfo.venueInfo_Id, venuefeatures = item }); } } db.SaveChanges(); VenueAddress venueaddress = new VenueAddress { vContactName = model.vContactName, vCity = model.vCity, vCountry = model.vCountry, vStreetAddress = model.vStreetAddress, vZipcode = Convert.ToInt32(model.vZipCode), vContactnum1 = model.vContactNumber1, vContactnum2 = model.vContactNumber2, venueInfo_id = venueinfo.venueInfo_Id, //, //vlang = Convert.ToDecimal(model.vlang), //vlong = Convert.ToDecimal(model.vlong) }; db.VenueAddresses.Add(venueaddress); db.SaveChanges(); string folderName = "venue-" + venueinfo.venueInfo_Id; string path = Server.MapPath("~/Uploads/" + folderName); Directory.CreateDirectory(path); int i = 1; foreach (var file in model.venuePhoto) { if (file != null) { string extension = Path.GetExtension(file.FileName); string namewithFullPath = Path.Combine(path + "/", i + extension); file.SaveAs(namewithFullPath); i++; } } return(RedirectToAction("Profile", "Dashboard")); } return(View(model)); }
// GET: /<controller>/ public IActionResult Index(string guid) { try { //B2d分銷商資料 var aesUserData = User.Identities.SelectMany(i => i.Claims.Where(c => c.Type == ClaimTypes.UserData).Select(c => c.Value)).FirstOrDefault(); var UserData = JsonConvert.DeserializeObject <B2dAccount>(AesCryptHelper.aesDecryptBase64(aesUserData, Website.Instance.AesCryptKey)); string ip = httpContextAccessor.HttpContext.Request.HttpContext.Connection.RemoteIpAddress.ToString().Replace("::1", "127.0.0.1"); //取挖字 Dictionary <string, string> uikey = CommonRepostory.getuiKey(RedisHelper, UserData.LOCALE);// RedisHelper.getuiKey(fakeContact.lang); ProdTitleModel title = JsonConvert.DeserializeObject <ProdTitleModel>(JsonConvert.SerializeObject(uikey)); if (guid == null) { throw new Exception(title.common_data_error); } confirmPkgInfo confirm = JsonConvert.DeserializeObject <confirmPkgInfo>(RedisHelper.getRedis("bid:ec:confirm:" + guid)); if (confirm == null) { throw new Exception(title.common_data_error); } //從 api取 ProductModuleModel module = ProductRepostory.getProdModule(UserData.COMPANY_XID, UserData.COUNRTY_CODE, UserData.LOCALE, UserData.CURRENCY, confirm.prodOid, confirm.pkgOid, title); ProductModel prod = ProductRepostory.getProdDtl(UserData.COMPANY_XID, UserData.COUNRTY_CODE, UserData.LOCALE, UserData.CURRENCY, confirm.prodOid, title); PackageModel pkgs = ProductRepostory.getProdPkg(UserData.COMPANY_XID, UserData.COUNRTY_CODE, UserData.LOCALE, UserData.CURRENCY, confirm.prodOid, title); if (prod.result != "0000") { Website.Instance.logger.Debug($"booking_index_getProdDtl_err:prodOid->{confirm.prodOid} ,msg-> {prod.result_msg}"); throw new Exception(title.result_code_9990); } if (pkgs.result != "0000") { Website.Instance.logger.Debug($"booking_index_getProdPkg_err:prodOid->{confirm.prodOid},pkgOid ->{confirm.pkgOid} ,msg-> {prod.result_msg}"); throw new Exception(title.result_code_9990); } string flightInfoType = ""; string sendInfoType = ""; PkgDetailModel pkg = null; PkgEventsModel pkgEvent = null; CusAgeRange cusAgeRange = null; string isEvent = "N"; string isHl = "N"; var pkgsTemp = pkgs.pkgs.Where(x => x.pkg_no == confirm.pkgOid).ToList(); if (pkgsTemp.Count() > 0) { foreach (PkgDetailModel p in pkgsTemp) { pkg = p; flightInfoType = p.module_setting.flight_info_type.value; sendInfoType = p.module_setting.send_info_type.value; cusAgeRange = BookingRepostory.getCusAgeRange(confirm, p); isEvent = p.is_event; isHl = p.is_hl; } } else { //丟錯誤頁 Website.Instance.logger.Debug($"booking_index_err:商編->{confirm.prodOid}即有pkgs找不到對應的pkgoid->{ confirm.pkgOid}"); throw new Exception(title.common_data_error); } //如果有event 但沒有傳 event id ,就error if (isEvent == "Y" && string.IsNullOrEmpty(confirm.pkgEvent)) { throw new Exception(title.common_data_error); } if (isEvent == "Y") { pkgEvent = ApiHelper.getPkgEvent(UserData.COMPANY_XID, UserData.COUNRTY_CODE, UserData.LOCALE, UserData.CURRENCY, confirm.prodOid, confirm.pkgOid, title); } //pmgw PmchLstResponse pmchRes = ApiHelper.getPaymentListRes(prod.countries, prod.prod_no.ToString(), DateTime.Now.ToString("yyyy-MM-dd"), DateTime.Now.ToString("yyyy-MM-dd"), DateTimeTool.yyyyMMdd2DateTime(confirm.selDate).ToString("yyyy-MM-dd"), DateTimeTool.yyyyMMdd2DateTime(confirm.selDate).ToString("yyyy-MM-dd"), UserData.COUNRTY_CODE, UserData.LOCALE, prod.prod_type, ip, prod.prod_hander, UserData.CURRENCY, title); Pmgw pmgw = null; if (UserData.CURRENCY == "TWD") { pmgw = pmchRes.pmchlist.Where(x => x.acctdocReceiveMethod == "ONLINE_CITI" && x.pmchCode == "B2D_CITI_TWD").FirstOrDefault(); } else { pmgw = pmchRes.pmchlist.Where(x => x.acctdocReceiveMethod == "ONLINE_HK_ADYEN").FirstOrDefault(); } //必須要設定人數 //var cusData = BookingRepostory.getCusDdate(); int totalCus = 0; if (module.module_cust_data != null) { if (module.module_cust_data.is_require == true) { totalCus = (module.module_cust_data.cus_type == "01") ? 1 : Convert.ToInt32(confirm.price1Qty + confirm.price2Qty + confirm.price3Qty + confirm.price4Qty); } } //滿足國家 List <Country> country = prod.countries; string nationName = ""; if (country.Count > 0) { nationName = country[0].name; } //將dataModel原型 以json str 帶到前台的hidden DataModel dm = DataSettingRepostory.getDefaultDataModel(totalCus, guid); dm.guidNo = guid; String dataModelStr = JsonConvert.SerializeObject(dm); //dm.travelerData[0].meal.mealType ViewData["dataModelStr"] = dataModelStr; VenueInfo venue = module.module_venue_info; if (venue == null) { venue = new VenueInfo(); venue.is_require = false; } RentCar rentCar = module.module_rent_car; if (rentCar == null) { rentCar = new RentCar(); rentCar.is_require = false; } ViewData["confirmPkgInfo"] = confirm; ViewData["contactInfo"] = UserData; ViewData["cusData"] = module.module_cust_data; ViewData["guide"] = module.module_guide_lang_list; ViewData["wifi"] = module.module_sim_wifi; ViewData["exchange"] = module.module_exchange_location_list; ViewData["flightInfo"] = module.module_flight_info; ViewData["venue"] = venue; // module.module_venue_info; ViewData["useDate"] = DateTimeTool.yyyy_mm_dd(confirm.selDate); //DateTimeTool.yyyy_mm_dd(); ViewData["rentCar"] = rentCar; // module.module_rent_car; ViewData["carPsgr"] = module.module_car_pasgr; //車輛資料 ViewData["sendData"] = module.module_send_data; ViewData["contactData"] = module.module_contact_data; ViewData["nationName"] = nationName; ViewData["guid"] = guid; ViewData["prodTitle"] = title; ViewData["totalCus"] = totalCus; ViewData["mainCat"] = prod.prod_type; ViewData["flightInfoType"] = flightInfoType; ViewData["sendInfoType"] = sendInfoType; ViewData["CutOfDay"] = prod.before_order_day; ViewData["cusAgeRange"] = cusAgeRange; BookingShowProdModel show = BookingRepostory.setBookingShowProd(prod, pkg, confirm, UserData.CURRENCY, pkgEvent, title); ViewData["prodShow"] = show; ViewData["isEvent"] = isEvent; // ViewData["isHl"] = isHl; //如果是N就不用做 ViewData["pkgCanUseDate"] = (isHl == "Y" && isEvent == "Y") ? BookingRepostory.getPkgEventDate(pkgEvent, confirm.pkgOid, (confirm.price1Qty + confirm.price2Qty + confirm.price3Qty + confirm.price4Qty)) : ""; //要把這個套餐可以用的日期全抓出來 ViewData["pmgw"] = pmgw; //放到session TempData["prod_" + guid] = JsonConvert.SerializeObject(prod); TempData["pkgEvent_" + guid] = (isHl == "Y" && isEvent == "Y") ? JsonConvert.SerializeObject(pkgEvent) : ""; TempData["module_" + guid] = JsonConvert.SerializeObject(module); TempData["confirm_" + guid] = JsonConvert.SerializeObject(confirm); TempData["ProdTitleKeep_" + guid] = JsonConvert.SerializeObject(title); TempData["pkg_" + guid] = JsonConvert.SerializeObject(pkg); TempData["pkgsDiscRule_" + guid] = JsonConvert.SerializeObject(pkgs.discount_rule); TempData["prodShow_" + guid] = JsonConvert.SerializeObject(show); TempData["pmgw_" + guid] = JsonConvert.SerializeObject(pmgw); return(View()); } catch (Exception ex) { ViewData["errMsg"] = ex.Message.ToString(); Website.Instance.logger.Debug($"booking_index_err:{ex.Message.ToString()}"); //導到錯誤頁 return(RedirectToAction("Index", "Error", new ErrorViewModel { ErrorType = ErrorType.Invalid_Common })); } }
public static string NameWithPlace(VenueInfo vi) { return vi.name + ", " + PlaceInfo.NameWithCountry(vi.place); }
/// <summary> /// On clicking CourseList button, calls CourseSearchService ClientList() method wtih test data. /// </summary> private void btnCourseList_Click(object sender, EventArgs e) { txtResult.Text = "Processing ..."; ServiceInterface client = new ServiceInterfaceClient("CourseSearch"); CourseListRequestStructure listRequestStructure = new CourseListRequestStructure(); listRequestStructure.CourseSearchCriteria = new SearchCriteriaStructure(); listRequestStructure.CourseSearchCriteria.SubjectKeyword = "chemistry"; // listRequestStructure.CourseSearchCriteria.ProviderID = "4517"; // 4517 University of Bristol listRequestStructure.CourseSearchCriteria.Location = "grantham"; // listRequestStructure.CourseSearchCriteria.Distance = 30.0f; // listRequestStructure.CourseSearchCriteria.DistanceSpecified = true; CourseListInput request = new CourseListInput(listRequestStructure); try { CourseListOutput response = client.CourseList(request); StringBuilder sb = new StringBuilder(); sb.Append("Request details:"); sb.Append("\nCourse Search Criteria:"); sb.Append("\n A10 codes: " + response.CourseListResponse.RequestDetails.CourseSearchCriteria.A10Codes); sb.Append("\n Adult LR status: " + response.CourseListResponse.RequestDetails.CourseSearchCriteria.AdultLRStatus); sb.Append("\n Attendance Modes: " + ((response.CourseListResponse.RequestDetails.CourseSearchCriteria.AttendanceModes != null) ? response.CourseListResponse.RequestDetails.CourseSearchCriteria.AttendanceModes.ToString() : "null")); sb.Append("\n Attendance Patterns: " + ((response.CourseListResponse.RequestDetails.CourseSearchCriteria.AttendancePatterns != null) ? response.CourseListResponse.RequestDetails.CourseSearchCriteria.AttendancePatterns.ToString() : "null")); sb.Append("\n Distance: " + response.CourseListResponse.RequestDetails.CourseSearchCriteria.Distance.ToString()); sb.Append("\n Distance specified: " + response.CourseListResponse.RequestDetails.CourseSearchCriteria.DistanceSpecified.ToString()); sb.Append("\n Earliest Start date: " + response.CourseListResponse.RequestDetails.CourseSearchCriteria.EarliestStartDate); sb.Append("\n ER app status: " + response.CourseListResponse.RequestDetails.CourseSearchCriteria.ERAppStatus); sb.Append("\n ER TTG status: " + response.CourseListResponse.RequestDetails.CourseSearchCriteria.ERTtgStatus); sb.Append("\n Flex start date: " + response.CourseListResponse.RequestDetails.CourseSearchCriteria.FlexStartFlag); sb.Append("\n IES flag: " + response.CourseListResponse.RequestDetails.CourseSearchCriteria.IESFlag); sb.Append("\n ILS flag: " + response.CourseListResponse.RequestDetails.CourseSearchCriteria.ILSFlag); sb.Append("\n LDCS Category code: " + ((response.CourseListResponse.RequestDetails.CourseSearchCriteria.LDCS != null) ? response.CourseListResponse.RequestDetails.CourseSearchCriteria.LDCS.CategoryCode.ToString() : "")); sb.Append("\n Location: " + response.CourseListResponse.RequestDetails.CourseSearchCriteria.Location); sb.Append("\n Opps App closed flag: " + response.CourseListResponse.RequestDetails.CourseSearchCriteria.OppsAppClosedFlag); sb.Append("\n Other funding status: " + response.CourseListResponse.RequestDetails.CourseSearchCriteria.OtherFundingStatus); sb.Append("\n Provider ID: " + response.CourseListResponse.RequestDetails.CourseSearchCriteria.ProviderID); sb.Append("\n Provider Keyword: " + response.CourseListResponse.RequestDetails.CourseSearchCriteria.ProviderKeyword); sb.Append("\n Qualification levels: " + ((response.CourseListResponse.RequestDetails.CourseSearchCriteria.QualificationLevels != null) ? response.CourseListResponse.RequestDetails.CourseSearchCriteria.QualificationLevels.ToString() : "null")); sb.Append("\n Qualification types: " + ((response.CourseListResponse.RequestDetails.CourseSearchCriteria.QualificationTypes != null) ? response.CourseListResponse.RequestDetails.CourseSearchCriteria.QualificationTypes.ToString() : "null")); sb.Append("\n SFL flag: " + response.CourseListResponse.RequestDetails.CourseSearchCriteria.SFLFlag); sb.Append("\n Study modes: " + ((response.CourseListResponse.RequestDetails.CourseSearchCriteria.StudyModes != null) ? response.CourseListResponse.RequestDetails.CourseSearchCriteria.StudyModes.ToString() : "null")); sb.Append("\n Subject keyword: " + response.CourseListResponse.RequestDetails.CourseSearchCriteria.SubjectKeyword); sb.Append("\n TQS flag: " + response.CourseListResponse.RequestDetails.CourseSearchCriteria.TQSFlag); sb.Append("\n TTG flag: " + response.CourseListResponse.RequestDetails.CourseSearchCriteria.TTGFlag); sb.Append("\n\n"); sb.Append("Course Details:"); if (response.CourseListResponse.CourseDetails != null) { foreach (CourseStructure courseStructure in response.CourseListResponse.CourseDetails) { sb.Append("\n" + courseStructure.Course.CourseID); sb.Append("\n" + courseStructure.Provider); sb.Append("\n" + courseStructure.Course.CourseTitle); sb.Append("\n" + courseStructure.Course.QualificationType); sb.Append("\n" + courseStructure.Course.QualificationLevel); sb.Append("\n" + courseStructure.Course.CourseSummary); sb.Append("\n" + courseStructure.Course.NoOfOpps); sb.Append("\n" + courseStructure.Opportunity.OpportunityId); sb.Append("\n" + courseStructure.Opportunity.StudyMode); sb.Append("\n" + courseStructure.Opportunity.AttendanceMode); sb.Append("\n" + courseStructure.Opportunity.AttendancePattern); sb.Append("\n" + courseStructure.Opportunity.StartDate.Item); sb.Append("\n" + courseStructure.Opportunity.Duration.DurationValue); sb.Append("\n" + courseStructure.Opportunity.Duration.DurationUnit); sb.Append("\n" + courseStructure.Opportunity.Duration.DurationDescription); if (courseStructure.Opportunity.Item.GetType() == typeof(VenueInfo)) { VenueInfo venue = (VenueInfo)courseStructure.Opportunity.Item; sb.Append("\n" + venue.VenueName); sb.Append("\n" + venue.Distance); sb.Append("\n" + venue.VenueAddress.Address_line_1); sb.Append("\n" + venue.VenueAddress.Address_line_2); sb.Append("\n" + venue.VenueAddress.Town); sb.Append("\n" + venue.VenueAddress.County); sb.Append("\n" + venue.VenueAddress.PostCode); sb.Append("\n" + venue.VenueAddress.Latitude); sb.Append("\n" + venue.VenueAddress.Longitude); } else { sb.Append("\n" + (string)courseStructure.Opportunity.Item); } sb.Append("\n"); } } sb.Append("\n\n"); sb.Append("Matching LDCS Details:"); if (response.CourseListResponse.MatchingLDCS != null) { foreach (CourseListResponseStructureMatchingLDCS mathcingLDCS in response.CourseListResponse.MatchingLDCS) { sb.Append("\n" + mathcingLDCS.LDCS.LDCSCode); sb.Append("\n" + mathcingLDCS.LDCS.LDCSDesc); sb.Append("\n" + mathcingLDCS.Counts); } } sb.Append("\n\n"); txtResult.Text = sb.ToString(); } catch (Exception ex) { txtResult.Text = ex.Message; } }
/// <summary> /// Build CourseListResponseStructure object from CourseListResponse data and original CourseListRequestStructure. /// </summary> /// <param name="response">CourseListResponse data.</param> /// <param name="request">Original CourseListRequestStructure.</param> /// <returns>Populated CourseListResponseStructure object.</returns> private static CourseListResponseStructure BuildCourseListResponseStructure(CourseListResponse response, CourseListRequestStructure request) { CourseListResponseStructure courseListResponse = new CourseListResponseStructure(); // Create matching Ldcs collection List <CourseListResponseStructureMatchingLDCS> matchingLdcss = new List <CourseListResponseStructureMatchingLDCS>(); foreach (LdcsCode ldcsCode in response.LdcsCodes) { CourseListResponseStructureMatchingLDCS matchingLdcs = new CourseListResponseStructureMatchingLDCS(); matchingLdcs.LDCS = BuildLdcsInfoType(ldcsCode.LdcsCodeValue, ldcsCode.LdcsCodeDescription); matchingLdcs.Counts = ldcsCode.CourseCount.ToString(); matchingLdcss.Add(matchingLdcs); } courseListResponse.MatchingLDCS = matchingLdcss.ToArray(); // Create CourseStructure collection List <CourseStructure> courseStructures = new List <CourseStructure>(); foreach (Course course in response.Courses) { // Get Course information CourseStructure courseStructure = new CourseStructure(); courseStructure.Course = new CourseInfo(); courseStructure.Course.CourseID = course.CourseId.ToString(); courseStructure.Course.CourseSummary = course.CourseSummary; courseStructure.Course.CourseTitle = course.CourseTitle; courseStructure.Course.LDCS = new LDCSOutputType(); courseStructure.Course.LDCS.CatCode1 = BuildLdcsInfoType(course.LdcsCode1, course.LdcsDesc1); courseStructure.Course.LDCS.CatCode2 = BuildLdcsInfoType(course.LdcsCode2, course.LdcsDesc2); courseStructure.Course.LDCS.CatCode3 = BuildLdcsInfoType(course.LdcsCode3, course.LdcsDesc3); courseStructure.Course.LDCS.CatCode4 = BuildLdcsInfoType(course.LdcsCode4, course.LdcsDesc4); courseStructure.Course.LDCS.CatCode5 = BuildLdcsInfoType(course.LdcsCode5, course.LdcsDesc5); courseStructure.Course.NoOfOpps = course.NumberOfOpportunities.ToString(); courseStructure.Course.QualificationLevel = course.QualificationLevel; courseStructure.Course.QualificationType = course.QualificationType; // Get Opportunity information List <OpportunityInfo> opportunityInfos = new List <OpportunityInfo>(); foreach (Opportunity opportunity in course.Opportunities) { OpportunityInfo opportunityInfo = new OpportunityInfo(); opportunityInfo.AttendanceMode = opportunity.AttendanceMode; opportunityInfo.AttendancePattern = opportunity.AttendancePattern; opportunityInfo.OpportunityId = opportunity.OpportunityId; StartDateType startDateType = BuildStartDateType(opportunity); //StartDateType startDateType = new StartDateType(); //startDateType.ItemElementName = ItemChoiceType.Date; //startDateType.Item = opportunity.StartDate; // TODO: how do we add these in? I suspect we need to change the contract. //StartDateType startDateDescType = new StartDateType(); //startDateDescType.ItemElementName = ItemChoiceType.DateDesc; //startDateDescType.Item = opportunity.StartDateDescription; opportunityInfo.StartDate = startDateType; opportunityInfo.Duration = new DurationType(); opportunityInfo.Duration.DurationDescription = opportunity.DurationDescription; opportunityInfo.Duration.DurationUnit = opportunity.DurationUnit; if (opportunity.DurationValue != 0) { opportunityInfo.Duration.DurationValue = opportunity.DurationValue.ToString(); } opportunityInfo.EndDate = opportunity.EndDate; opportunityInfo.StudyMode = opportunity.StudyMode; opportunityInfo.DFE1619Funded = opportunity.DfE1619Funded; opportunityInfo.DFE1619FundedSpecified = true; if (opportunity.Venue != null && !string.IsNullOrEmpty(opportunity.Venue.VenueName)) { VenueInfo venueInfo = new VenueInfo(); if (!string.IsNullOrEmpty(opportunity.Distance)) { venueInfo.DistanceSpecified = true; venueInfo.Distance = float.Parse(opportunity.Distance); } venueInfo.VenueName = opportunity.Venue.VenueName; venueInfo.VenueAddress = BuildAddressType(opportunity.Venue.AddressLine1, opportunity.Venue.AddressLine2, opportunity.Venue.Town, opportunity.Venue.County, opportunity.Venue.Postcode, opportunity.Venue.Latitude, opportunity.Venue.Longitude); opportunityInfo.Item = venueInfo; } else { opportunityInfo.Item = opportunity.RegionName; } opportunityInfos.Add(opportunityInfo); } // pick out the first opportunity (expecting there to be only one looking at the java web service's design). // if there is more than one here - then current site cannot deal with it. courseStructure.Opportunity = opportunityInfos.ElementAt(0); courseStructure.Provider = new ProviderInfo(); courseStructure.Provider.ProviderName = course.Provider.ProviderName; courseStructure.Provider.TFPlusLoans = course.Provider.TFPlusLoans; courseStructure.Provider.TFPlusLoansSpecified = true; courseStructure.Provider.DFE1619Funded = course.Provider.DFE1619Funded; courseStructure.Provider.DFE1619FundedSpecified = true; if (course.Provider.FEChoices_EmployerSatisfaction.HasValue) { courseStructure.Provider.FEChoices_EmployerSatisfaction = course.Provider.FEChoices_EmployerSatisfaction.Value; } courseStructure.Provider.FEChoices_EmployerSatisfactionSpecified = course.Provider.FEChoices_EmployerSatisfaction.HasValue; if (course.Provider.FEChoices_LearnerSatisfaction.HasValue) { courseStructure.Provider.FEChoices_LearnerSatisfaction = course.Provider.FEChoices_LearnerSatisfaction.Value; } courseStructure.Provider.FEChoices_LearnerSatisfactionSpecified = course.Provider.FEChoices_LearnerSatisfaction.HasValue; if (course.Provider.FEChoices_LearnerDestination.HasValue) { courseStructure.Provider.FEChoices_LearnerDestination = course.Provider.FEChoices_LearnerDestination.Value; } courseStructure.Provider.FEChoices_LearnerDestinationSpecified = course.Provider.FEChoices_LearnerDestination.HasValue; courseStructures.Add(courseStructure); } courseListResponse.CourseDetails = courseStructures.ToArray(); // Get Result information, i.e. page number etc. courseListResponse.ResultInfo = new ResultInfoType(); int requestRecordsPerPage = 0; if (!string.IsNullOrEmpty(request.RecordsPerPage)) { requestRecordsPerPage = Int32.Parse(request.RecordsPerPage); } int responseRecordsPerPage = (requestRecordsPerPage > 0) ? requestRecordsPerPage : 50; int totalRecords = response.NumberOfRecords; int numberOfPages = (totalRecords / responseRecordsPerPage) + ((totalRecords % responseRecordsPerPage == 0) ? 0 : 1); int currentPage = 1; if (!string.IsNullOrEmpty(request.PageNo)) { currentPage = Int32.Parse(request.PageNo); } courseListResponse.ResultInfo.NoOfRecords = response.NumberOfRecords.ToString(); courseListResponse.ResultInfo.PageNo = (currentPage > 0) ? currentPage.ToString() : "1"; courseListResponse.ResultInfo.NoOfPages = numberOfPages.ToString(); // Get original Request details courseListResponse.RequestDetails = request; return(courseListResponse); }
/// <summary> /// Creates a repeater friendly CourseSearchResult object from the response. /// </summary> /// <param name="course">The CourseStructure response from the search.</param> /// <returns>A populated CourseSearchResult object.</returns> private CourseSearchResult CreateResult(CourseStructure course) { CourseSearchResult result = new CourseSearchResult(); if (course != null && course.Course != null) { // COURSE result.CourseID = HttpUtility.HtmlEncode(course.Course.CourseID); result.CourseName = HttpUtility.HtmlEncode(course.Course.CourseTitle); result.CourseSummary = HttpUtility.HtmlEncode(course.Course.CourseSummary); result.CourseDfEFunded = course.Opportunity.DFE1619Funded; result.LDCS1 = HttpUtility.HtmlEncode(course.Course.LDCS.CatCode1.LDCSCode); result.LDCS1Description = HttpUtility.HtmlEncode(course.Course.LDCS.CatCode1.LDCSDesc); result.LDCS2 = HttpUtility.HtmlEncode(course.Course.LDCS.CatCode2.LDCSCode); result.LDCS2Description = HttpUtility.HtmlEncode(course.Course.LDCS.CatCode2.LDCSDesc); result.LDCS3 = HttpUtility.HtmlEncode(course.Course.LDCS.CatCode3.LDCSCode); result.LDCS3Description = HttpUtility.HtmlEncode(course.Course.LDCS.CatCode3.LDCSDesc); result.LDCS4 = HttpUtility.HtmlEncode(course.Course.LDCS.CatCode4.LDCSCode); result.LDCS4Description = HttpUtility.HtmlEncode(course.Course.LDCS.CatCode4.LDCSDesc); result.LDCS5 = HttpUtility.HtmlEncode(course.Course.LDCS.CatCode5.LDCSCode); result.LDCS5Description = HttpUtility.HtmlEncode(course.Course.LDCS.CatCode5.LDCSDesc); result.NumberOfOpportunities = HttpUtility.HtmlEncode(course.Course.NoOfOpps); result.QualificationLevel = HttpUtility.HtmlEncode(course.Course.QualificationLevel); result.QualificationType = HttpUtility.HtmlEncode(course.Course.QualificationType); // OPPORTUNITY if (course.Opportunity != null) { result.OpportunityID = HttpUtility.HtmlEncode(course.Opportunity.OpportunityId); result.AttendanceMode = HttpUtility.HtmlEncode(course.Opportunity.AttendanceMode); result.AttendancePattern = HttpUtility.HtmlEncode(course.Opportunity.AttendancePattern); if (course.Opportunity.Duration != null) { result.DurationDescription = HttpUtility.HtmlEncode(course.Opportunity.Duration.DurationDescription); result.DurationUnit = HttpUtility.HtmlEncode(course.Opportunity.Duration.DurationUnit); result.DurationValue = HttpUtility.HtmlEncode(course.Opportunity.Duration.DurationValue); } if (course.Opportunity.Item != null) { // could be VenueInfo or a Region name if (course.Opportunity.Item.GetType() == typeof(VenueInfo)) { VenueInfo venueInfo = course.Opportunity.Item as VenueInfo; if (venueInfo != null) { result.Venue = venueInfo.VenueName; result.Distance = venueInfo.Distance.ToString(); if (venueInfo.VenueAddress != null) { result.AddressLine1 = venueInfo.VenueAddress.Address_line_1; result.AddressLine2 = venueInfo.VenueAddress.Address_line_2; result.Town = venueInfo.VenueAddress.Town; result.County = venueInfo.VenueAddress.County; result.Postcode = venueInfo.VenueAddress.PostCode; result.Latitude = venueInfo.VenueAddress.Latitude; result.Longitude = venueInfo.VenueAddress.Longitude; } } } else if (course.Opportunity.Item is String) { result.RegionName = course.Opportunity.Item.ToString(); } } if (course.Opportunity.StartDate.ItemElementName.ToString() == "Date") { if (course.Opportunity.StartDate.Item != null) { result.StartDate = course.Opportunity.StartDate.Item; } } else { result.StartDateDescription = course.Opportunity.StartDate.Item; } result.StudyMode = HttpUtility.HtmlEncode(course.Opportunity.StudyMode); } result.OpportunityID = HttpUtility.HtmlEncode(course.Opportunity.OpportunityId); // PROVIDER result.ProviderName = HttpUtility.HtmlEncode(course.Provider.ProviderName); result.TFPlusLoans = course.Provider.TFPlusLoans; result.ProviderDfEFunded = course.Provider.DFE1619Funded; result.FEChoices_LearnerDestination = course.Provider.FEChoices_LearnerDestinationSpecified ? course.Provider.FEChoices_LearnerDestination : (Double?)null; result.FEChoices_LearnerSatisfaction = course.Provider.FEChoices_LearnerSatisfactionSpecified ? course.Provider.FEChoices_LearnerSatisfaction : (Double?)null; result.FEChoices_EmployerSatisfaction = course.Provider.FEChoices_EmployerSatisfactionSpecified ? course.Provider.FEChoices_EmployerSatisfaction : (Double?)null; } return(result); }