public void CreateRequest_RequestVersionProperties(string versionString) { var version = versionString != null?Version.Parse(versionString) : null; var clusterModel = GetClusterConfig("cluster0", new ActiveHealthCheckConfig() { Enabled = true, Policy = "policy", }, version #if NET , HttpVersionPolicy.RequestVersionExact #endif ); var destinationModel = new DestinationModel(new DestinationConfig { Address = "https://localhost:10000/" }); var factory = new DefaultProbingRequestFactory(); var request = factory.CreateRequest(clusterModel, destinationModel); Assert.Equal(version ?? HttpVersion.Version20, request.Version); #if NET Assert.Equal(HttpVersionPolicy.RequestVersionExact, request.VersionPolicy); #endif }
protected virtual void UpdateLocales(Destination destination, DestinationModel model) { foreach (var localized in model.Locales) { _localizedEntityService.SaveLocalizedValue(destination, x => x.Name, localized.Name, localized.LanguageId); _localizedEntityService.SaveLocalizedValue(destination, x => x.Description, localized.Description, localized.LanguageId); _localizedEntityService.SaveLocalizedValue(destination, x => x.MetaKeywords, localized.MetaKeywords, localized.LanguageId); _localizedEntityService.SaveLocalizedValue(destination, x => x.MetaDescription, localized.MetaDescription, localized.LanguageId); _localizedEntityService.SaveLocalizedValue(destination, x => x.MetaTitle, localized.MetaTitle, localized.LanguageId); //search engine name var seName = destination.ValidateSeName(localized.SeName, localized.Name, false); _urlRecordService.SaveSlug(destination, seName, localized.LanguageId); } }
public async Task <Object> AddDestination(DestinationModel model) { var airline = await _context.Airlines.FindAsync(int.Parse(model.AirlineID)); if (airline != null) { Destination destination = new Destination() { AirportName = model.AirportName, City = model.City, Country = model.Country, Airline = airline }; try { var result = await _context.Destinations.AddAsync(destination); _context.SaveChanges(); return(Ok()); } catch (Exception e) { throw e; } } else { return(BadRequest("Add destination is unsuccessffully.Server not found selected airline.")); } }
public void init() { float x = Random.Range(0f, 1f); float y = Random.Range(0f, 1f); // print (x + ", " + y); if (x < .5f) { x = GameManager.x_coord * GameManager.BGSCALE * -1; } else { x = GameManager.x_coord * GameManager.BGSCALE; } if (y < .5f) { y = GameManager.y_coord * GameManager.BGSCALE * -1; } else { y = GameManager.y_coord * GameManager.BGSCALE; } this.modelObject = GameObject.CreatePrimitive(PrimitiveType.Quad); this.gameObject.transform.position = new Vector3(x, y, 0); dmodel = modelObject.AddComponent <DestinationModel> (); dmodel.init(this); this.modelObject.transform.position = gameObject.transform.position; // this.gameObject.AddComponent<BoxCollider2D> (); print(x + " " + y); }
public async Task <Object> ChangeDestination(DestinationModel model) { var resultFind = await _context.Destinations.FindAsync(int.Parse(model.AirlineID)); if (resultFind == null) { return(NotFound()); } if (model.AirportName == null && model.City == null && model.Country == null) { return(NotFound("Change unsccessfully.All field are empty.")); } if (model.AirportName.Trim().Equals("") && model.City.Trim().Equals("") && model.Country.Trim().Equals("")) { return(NotFound("Change unsccessfully.All field are empty.")); } resultFind.AirportName = model.AirportName == null || model.AirportName.Trim().Equals("") ? resultFind.AirportName : model.AirportName; resultFind.City = model.City == null || model.City.Trim().Equals("") ? resultFind.City : model.City; resultFind.Country = model.Country == null || model.Country.Trim().Equals("") ? resultFind.Country : model.Country; try { _context.Destinations.Update(resultFind); _context.SaveChanges(); return(Ok()); } catch (Exception e) { throw e; } }
public virtual ActionResult Create() { if (!_permissionService.Authorize(StandardPermissionProvider.ManageDestinations)) { return(AccessDeniedView()); } var model = new DestinationModel(); //locales AddLocales(_languageService, model.Locales); //templates PrepareTemplatesModel(model); //discounts PrepareDiscountModel(model, null, true); //ACL PrepareAclModel(model, null, false); //Stores PrepareStoresMappingModel(model, null, false); //default values model.PageSize = _catalogSettings.DefaultDestinationPageSize; model.PageSizeOptions = _catalogSettings.DefaultDestinationPageSizeOptions; model.Published = true; model.AllowCustomersToSelectPageSize = true; return(View(model)); }
protected virtual void SaveStoreMappings(Destination destination, DestinationModel model) { destination.LimitedToStores = model.SelectedStoreIds.Any(); var existingStoreMappings = _storeMappingService.GetStoreMappings(destination); var allStores = _storeService.GetAllStores(); foreach (var store in allStores) { if (model.SelectedStoreIds.Contains(store.Id)) { //new store if (existingStoreMappings.Count(sm => sm.StoreId == store.Id) == 0) { _storeMappingService.InsertStoreMapping(destination, store.Id); } } else { //remove store var storeMappingToDelete = existingStoreMappings.FirstOrDefault(sm => sm.StoreId == store.Id); if (storeMappingToDelete != null) { _storeMappingService.DeleteStoreMapping(storeMappingToDelete); } } } }
public void TestCallsIntermediateTransformersWhenPushing() { SourceModel sourceModel = new SourceModel(); IntermediateModel intermediateModel = new IntermediateModel(); DestinationModel destinationModel = new DestinationModel(); Mock <ITransformer <SourceModel, IntermediateModel> > firstTransformerMock = new Mock <ITransformer <SourceModel, IntermediateModel> >(); Mock <ITransformer <IntermediateModel, DestinationModel> > secondTransformerMock = new Mock <ITransformer <IntermediateModel, DestinationModel> >(); Mock <ITransformer <DestinationModel, IntermediateModel> > thirdTransformerMock = new Mock <ITransformer <DestinationModel, IntermediateModel> >(); Mock <ITransformer <IntermediateModel, SourceModel> > fourthTransformerMock = new Mock <ITransformer <IntermediateModel, SourceModel> >(); firstTransformerMock.Setup(_ => _.Transform(sourceModel)).Returns(intermediateModel).Verifiable(); secondTransformerMock.Setup(_ => _.Transform(intermediateModel)).Returns(destinationModel).Verifiable(); thirdTransformerMock.Setup(_ => _.Transform(destinationModel)).Returns(intermediateModel).Verifiable(); fourthTransformerMock.Setup(_ => _.Transform(intermediateModel)).Returns(sourceModel).Verifiable(); TransformerPipeline <SourceModel, IntermediateModel, DestinationModel> transformer = new TransformerPipeline <SourceModel, IntermediateModel, DestinationModel>( firstTransformerMock.Object, secondTransformerMock.Object ); ITransformer <SourceModel, SourceModel> newTransformer = transformer .PipePush(thirdTransformerMock.Object) .PipePush(fourthTransformerMock.Object); newTransformer.Transform(sourceModel); firstTransformerMock.Verify(_ => _.Transform(sourceModel), Times.Once); secondTransformerMock.Verify(_ => _.Transform(intermediateModel), Times.Once); thirdTransformerMock.Verify(_ => _.Transform(destinationModel), Times.Once); fourthTransformerMock.Verify(_ => _.Transform(intermediateModel), Times.Once); }
protected virtual void SaveDestinationAcl(Destination destination, DestinationModel model) { destination.SubjectToAcl = model.SelectedCustomerRoleIds.Any(); var existingAclRecords = _aclService.GetAclRecords(destination); var allCustomerRoles = _customerService.GetAllCustomerRoles(true); foreach (var customerRole in allCustomerRoles) { if (model.SelectedCustomerRoleIds.Contains(customerRole.Id)) { //new role if (existingAclRecords.Count(acl => acl.CustomerRoleId == customerRole.Id) == 0) { _aclService.InsertAclRecord(destination, customerRole.Id); } } else { //remove role var aclRecordToDelete = existingAclRecords.FirstOrDefault(acl => acl.CustomerRoleId == customerRole.Id); if (aclRecordToDelete != null) { _aclService.DeleteAclRecord(aclRecordToDelete); } } } }
public ActionResult SearchDestinations(string destinationName, string destinationParentId, string destinationParentName, string destinationParentType, string userKey) { #if DEBUG if (string.IsNullOrEmpty(userKey)) { userKey = "1BB43EC1-2DBE-4DD7-ABD8-17890AFC0E69"; } #endif SessionData.UserCredential = Manager.GetCredential(userKey); if (destinationName == null) { destinationName = string.Empty; } DestinationModel parent = null; if (!(string.IsNullOrWhiteSpace(destinationParentId) || string.IsNullOrWhiteSpace(destinationParentName) || string.IsNullOrWhiteSpace(destinationParentType))) { parent = new DestinationModel { DestinationId = destinationParentId, DestinationName = destinationParentName, DestinationType = (DestinationType)Enum.Parse(typeof(DestinationType), destinationParentType) }; } return(Json(Manager.SearchDestination(destinationName, SessionData.UserCredential, parent).Destinations, JsonRequestBehavior.AllowGet)); }
public async Task <IActionResult> SearchBestPlaceToGo(DestinationModel bestDestination) { var shortList = new List <CountryData>(); CountryData departureCountry = null; try { switch (bestDestination.Weather) { //case "Any": { tMax = 100; tMin = -100; }; break; //case "Hot": { tMax = 100; tMin = 18; }; break; //case "Warm": { tMax = 30; tMin = 12; }; break; //case "Cold": { tMax = 15; tMin = -100; }; break; default:; break; } if (!MemoryCache.TryGetValue("GeoCountryList", out List <CountryData> countries)) { using (var client = new HttpClient()) { var countriesString = await client.GetStringAsync(string.Format("{0}/visa/map", Endpoint)); countries = JsonConvert.DeserializeObject <List <CountryData> >(countriesString); var memoryCacheOptions = new MemoryCacheEntryOptions() .SetAbsoluteExpiration(TimeSpan.FromDays(5)); MemoryCache.Set("GeoCountryList", countries, memoryCacheOptions); } } // first reduction departureCountry = countries.FirstOrDefault(c => string.Equals(c.Name, bestDestination.DepartureCountryName, StringComparison.CurrentCultureIgnoreCase)); //visa free only, planning to do it for any kind of visa, but it doesn't make sense so far if (bestDestination.VisaType == "VF") { shortList = countries.Where(c => departureCountry.VFCountries.Contains(c.Alpha2Code)) .Where(c => c.Region.Equals("World") || string.Equals(c.Region, bestDestination.Area, StringComparison.CurrentCultureIgnoreCase)) .ToList(); } else { shortList = countries.Where(c => c.Region.Equals("World") || string.Equals(c.Region, bestDestination.Area, StringComparison.CurrentCultureIgnoreCase)) .ToList(); shortList.Remove(departureCountry); } } catch (Exception exception) { Console.WriteLine("Destination exception:" + exception.Message); } ViewBag.Month = bestDestination.Month == "now" ? "" + DateTime.Now.Month : bestDestination.Month; return(View(new BestDestinationDto(shortList, departureCountry))); }
public void UpdateModel_WFDictionaryValueProvider() { Dictionary <string, string> valueDict = new Dictionary <string, string>(); WFDictionaryValueProvider vp = new WFDictionaryValueProvider(valueDict); DestinationModel dm = new DestinationModel(); WFPageUtilities.UpdateModel(vp, typeof(DestinationModel), "", null, null); }
public DestinationModel GetDestinationByUrl(string url) { var rs = new DestinationModel(); var contents = _unitOfWork.ContentRepository.FindAll(x => x.UrlName.Equals(url)); if (contents.Any()) { int DestinationId = contents.FirstOrDefault().DestinationId.Value; rs = Parse(_unitOfWork.DestinationRepository.Find(DestinationId)); } return(rs); }
private DestinationModel Parse(Destination source, int currentLanguage = 1) { var item = new DestinationModel(); var content = source.Contents.FirstOrDefault(c => c.LanguageId == currentLanguage) ?? source.Contents.FirstOrDefault(); item.Id = source.Id; item.ParentId = source.ParentId; item.DisplayName = content.DisplayName; item.UrlName = content.UrlName; return(item); }
//change to static because doesn't have properties public static List <DestinationModel> PresetDestinations() { List <DestinationModel> destinations = new List <DestinationModel>(); DestinationModel auckland = new DestinationModel(); auckland.Id = new Guid("00000000-0000-0000-0000-00000000000A"); auckland.Name = "Auckland"; auckland.Region = "North Island"; auckland.Country = "New Zealand"; auckland.Latitude = -36.850933; auckland.Longitude = 174.764491; DestinationModel hamilton = new DestinationModel(); hamilton.Id = new Guid("00000000-0000-0000-0000-00000000000B"); hamilton.Name = "Hamilton"; hamilton.Region = "North Island"; hamilton.Country = "New Zealand"; hamilton.Latitude = -37.787221; hamilton.Longitude = 175.283010; DestinationModel rotorua = new DestinationModel(); rotorua.Id = new Guid("00000000-0000-0000-0000-00000000000C"); rotorua.Name = "Rotorua"; rotorua.Region = "North Island"; rotorua.Country = "New Zealand"; rotorua.Latitude = -38.135376; rotorua.Longitude = 176.253787; DestinationModel wellington = new DestinationModel(); wellington.Id = new Guid("00000000-0000-0000-0000-00000000000D"); wellington.Name = "Wellington"; wellington.Region = "North Island"; wellington.Country = "New Zealand"; wellington.Latitude = -41.286453; wellington.Longitude = 174.776238; destinations.Add(auckland); destinations.Add(hamilton); destinations.Add(rotorua); destinations.Add(wellington); return(destinations); }
/// <summary> /// Add Destination asynchronous. /// </summary> /// <param name="model">The Destination Record.</param> /// <returns> /// Add Destination Async /// </returns> /// <exception cref="ArgumentNullException">Destination</exception> public async Task <int> AddDestinationAsync(DestinationModel model) { try { if (model == null) { throw new ArgumentNullException("Destination"); } return(await this.destinationRespository.InsertAsync(model)); } catch (Exception ex) { throw ex; } }
public async Task <IActionResult> AddDestination(DestinationModel destination) { //context.Destinations.Add(destination); Aircompany company = context.Aircompanies.Include(x => x.Destinations).SingleOrDefault(x => x.Id == destination.Aircompany); company.Destinations.Add(new Destination() { City = destination.City }); await context.SaveChangesAsync(); //await context.SaveChangesAsync(); return(Ok()); }
public void CreateRequest_HealthEndpointIsNotDefined_UseDestinationAddress(string address, string health, string healthPath, string expectedRequestUri) { var clusterModel = GetClusterConfig("cluster0", new ActiveHealthCheckConfig() { Enabled = true, Policy = "policy", Path = healthPath, }, HttpVersion.Version20); var destinationModel = new DestinationModel(new DestinationConfig { Address = address, Health = health }); var factory = new DefaultProbingRequestFactory(); var request = factory.CreateRequest(clusterModel, destinationModel); Assert.Equal(expectedRequestUri, request.RequestUri.AbsoluteUri); }
public HttpRequestMessage CreateRequest(ClusterModel cluster, DestinationModel destination) { var probeAddress = !string.IsNullOrEmpty(destination.Config.Health) ? destination.Config.Health : destination.Config.Address; var probePath = cluster.Config.HealthCheck?.Active?.Path; UriHelper.FromAbsolute(probeAddress, out var destinationScheme, out var destinationHost, out var destinationPathBase, out _, out _); var probeUri = UriHelper.BuildAbsolute(destinationScheme, destinationHost, destinationPathBase, probePath, default); var request = new HttpRequestMessage(HttpMethod.Get, probeUri) { Version = cluster.Config.HttpRequest?.Version ?? HttpVersion.Version20, VersionPolicy = cluster.Config.HttpRequest?.VersionPolicy ?? HttpVersionPolicy.RequestVersionOrLower, }; request.Headers.Add(HeaderNames.UserAgent, _defaultUserAgent); return(request); }
protected virtual void PrepareTemplatesModel(DestinationModel model) { if (model == null) { throw new ArgumentNullException("model"); } var templates = _destinationTemplateService.GetAllDestinationTemplates(); foreach (var template in templates) { model.AvailableDestinationTemplates.Add(new SelectListItem { Text = template.Name, Value = template.Id.ToString() }); } }
public async Task <CommandResult <Guid> > CreateDestination(DestinationModel model) { try { if (model.DestinationId == null || model.DestinationId == Guid.Empty) { model.DestinationId = Guid.NewGuid(); } var destination = _mapper.Map <DestinationModel, DestinationEntity>(model); await _destinationRepository.Add(destination); return(new CommandResult <Guid>(destination.DestinationId)); } catch (Exception exception) { return(new CommandResult <Guid>(exception.Message)); } }
private ClusterState GetClusterInfo(string id, int destinationCount, int?failureThreshold = null) { var metadata = failureThreshold != null ? new Dictionary <string, string> { { ConsecutiveFailuresHealthPolicyOptions.ThresholdMetadataName, failureThreshold.ToString() } } : null; var clusterModel = new ClusterModel( new ClusterConfig { ClusterId = id, HealthCheck = new HealthCheckConfig() { Active = new ActiveHealthCheckConfig { Enabled = true, Policy = "policy", Path = "/api/health/", }, }, Metadata = metadata, }, new HttpMessageInvoker(new HttpClientHandler())); var clusterState = new ClusterState(id); clusterState.Model = clusterModel; for (var i = 0; i < destinationCount; i++) { var destinationModel = new DestinationModel(new DestinationConfig { Address = $"https://localhost:1000{i}/{id}/", Health = $"https://localhost:2000{i}/{id}/" }); var destinationId = $"destination{i}"; clusterState.Destinations.GetOrAdd(destinationId, id => new DestinationState(id) { Model = destinationModel }); } clusterState.DestinationsState = new ClusterDestinationsState(clusterState.Destinations.Values.ToList(), clusterState.Destinations.Values.ToList()); return(clusterState); }
private ClusterState GetClusterInfo(string id, int destinationCount, double?failureRateLimit = null, TimeSpan?reactivationPeriod = null) { var metadata = failureRateLimit != null ? new Dictionary <string, string> { { TransportFailureRateHealthPolicyOptions.FailureRateLimitMetadataName, failureRateLimit?.ToString(CultureInfo.InvariantCulture) } } : null; var clusterModel = new ClusterModel( new ClusterConfig { ClusterId = id, HealthCheck = new HealthCheckConfig { Passive = new PassiveHealthCheckConfig { Enabled = true, Policy = "policy", ReactivationPeriod = reactivationPeriod, } }, Metadata = metadata, }, new HttpMessageInvoker(new HttpClientHandler())); var clusterState = new ClusterState(id); clusterState.Model = clusterModel; for (var i = 0; i < destinationCount; i++) { var destinationModel = new DestinationModel(new DestinationConfig { Address = $"https://localhost:1000{i}/{id}/", Health = $"https://localhost:2000{i}/{id}/" }); var destinationId = $"destination{i}"; clusterState.Destinations.GetOrAdd(destinationId, id => new DestinationState(id) { Model = destinationModel }); } return(clusterState); }
protected virtual void PrepareDiscountModel(DestinationModel model, Destination destination, bool excludeProperties) { if (model == null) { throw new ArgumentNullException("model"); } if (!excludeProperties && destination != null) { model.SelectedDiscountIds = destination.AppliedDiscounts.Select(d => d.Id).ToList(); } foreach (var discount in _discountService.GetAllDiscounts(DiscountType.AssignedToDestinations, showHidden: true)) { model.AvailableDiscounts.Add(new SelectListItem { Text = discount.Name, Value = discount.Id.ToString(), Selected = model.SelectedDiscountIds.Contains(discount.Id) }); } }
public void TestReturnsDataFromLastTransformer() { Mock <ITransformer <SourceModel, IntermediateModel> > leftTransformerMock = new Mock <ITransformer <SourceModel, IntermediateModel> >(); Mock <ITransformer <IntermediateModel, DestinationModel> > rightTransformerMock = new Mock <ITransformer <IntermediateModel, DestinationModel> >(); SourceModel sourceData = new SourceModel(); IntermediateModel intermediateData = new IntermediateModel(); DestinationModel destinationData = new DestinationModel(); leftTransformerMock.Setup(_ => _.Transform(sourceData)).Returns(intermediateData); rightTransformerMock.Setup(_ => _.Transform(intermediateData)).Returns(destinationData); ITransformer <SourceModel, DestinationModel> tranformer = new TransformerPipeline <SourceModel, IntermediateModel, DestinationModel>( leftTransformerMock.Object, rightTransformerMock.Object ); DestinationModel resultData = tranformer.Transform(sourceData); Assert.AreEqual(destinationData, resultData); }
protected virtual void PrepareStoresMappingModel(DestinationModel model, Destination destination, bool excludeProperties) { if (model == null) { throw new ArgumentNullException("model"); } if (!excludeProperties && destination != null) { model.SelectedStoreIds = _storeMappingService.GetStoresIdsWithAccess(destination).ToList(); } var allStores = _storeService.GetAllStores(); foreach (var store in allStores) { model.AvailableStores.Add(new SelectListItem { Text = store.Name, Value = store.Id.ToString(), Selected = model.SelectedStoreIds.Contains(store.Id) }); } }
protected virtual void PrepareAclModel(DestinationModel model, Destination destination, bool excludeProperties) { if (model == null) { throw new ArgumentNullException("model"); } if (!excludeProperties && destination != null) { model.SelectedCustomerRoleIds = _aclService.GetCustomerRoleIdsWithAccess(destination).ToList(); } var allRoles = _customerService.GetAllCustomerRoles(true); foreach (var role in allRoles) { model.AvailableCustomerRoles.Add(new SelectListItem { Text = role.Name, Value = role.Id.ToString(), Selected = model.SelectedCustomerRoleIds.Contains(role.Id) }); } }
public static Destination ToEntity(this DestinationModel model) { return(model.MapTo <DestinationModel, Destination>()); }
public static Destination ToEntity(this DestinationModel model, Destination destination) { return(model.MapTo(destination)); }
public void ValidateModel(DestinationModel destinationModel) { throw new NotImplementedException(); }