public async Task <IActionResult> GetGroup([FromQuery] GroupParameters parameters) { try { //验证排序的字段是否存在 if (!propertyMappingContainer.ValidateMappingExistsFor <GroupViewModel, Group>(parameters.OrderBy)) { return(BadRequest("order by Fidled not exist")); } //验证过滤的字段是否存在 if (!typeHelperService.TypeHasProperties <GroupViewModel>(parameters.Fields)) { return(BadRequest("fidled not exist")); } var users = await repository.GetAllGroupsAsync(parameters); var userViewModel = mapper.Map <IEnumerable <Group>, IEnumerable <GroupViewModel> >(users); var shapedViewModel = userViewModel.ToDynamicIEnumerable(parameters.Fields); return(Ok(new BaseResponse() { success = true, dynamicObj = shapedViewModel, TotalRecord = users.TotalItemsCount })); } catch (Exception ex) { return(Ok(new BaseResponse() { success = false, message = ex.Message })); } }
public async Task <GroupResponse> GetGroupsAsync(GroupParameters parameters) { BaseServiceRequest <GroupResponse> baseService = new BaseServiceRequest <GroupResponse>(); var r = await baseService.GetRequest(new GroupRequest() { parameters = parameters }); return(r); }
private void buttonDodajParametr_Click(object sender, RoutedEventArgs e) { try { GroupParameters nextParameter = new GroupParameters(ParametersNameTxtBox.Text.ToString(), Int32.Parse(ParametersSizeTextBox.Text.ToString()), Int32.Parse(ParametersDensityTextBox.Text.ToString())); parametersList.Add(nextParameter); ParametersDataGrid.Items.Refresh(); } catch (Exception) { MessageBox.Show("Fill up rquied fields", "No text", MessageBoxButton.OK, MessageBoxImage.Warning); } }
public async Task <PaginatedList <Group> > GetAllGroupsAsync(GroupParameters parameters) { var query = context.Groups.AsQueryable(); if (!string.IsNullOrEmpty(parameters.Search)) { var serach = parameters.Search.ToLowerInvariant(); query = query.Where(t => t.GroupCode.ToLowerInvariant().Contains(serach) || t.GroupName.ToLowerInvariant().Contains(serach)); } query = query.ApplySort(parameters.OrderBy, propertyMappingContainer.Resolve <GroupViewModel, Group>()); var count = await query.CountAsync(); var data = await query.Skip(parameters.PageIndex - 1 *parameters.PageSize).Take(parameters.PageSize).ToListAsync(); return(new PaginatedList <Group>(parameters.PageIndex - 1, parameters.PageSize, count, data)); }
public async Task <IActionResult> GetGroupsWithPage([FromQuery] GroupParameters groupParameters) { var find = await _context.Groups .Where(s => EF.Functions.Like(s.Id.ToString(), $"%{groupParameters.Text}%") || EF.Functions.Like(s.Name, $"%{groupParameters.Text}%") ).ToListAsync(); groupParameters.TotalCount = find.Count; if (!groupParameters.Check()) { return(NoContent()); } Response.Headers.Add("X-Pagination", groupParameters.PaginationToJson()); List <GroupDTO> dtos = new List <GroupDTO>(); foreach (var item in find) { dtos.Add(item.ToGroupDto()); } return(Ok(dtos)); }
// Update is called once per frame void Update() { if (this.ready) { Debug.Log("Updateamos"); if (this.firstTime) { this.firstTime = false; Debug.Log("Simulación " + this._simulationCounter); this._predatorParameters = new GroupParameters(this.reproductionPredator, this.maxSpeedPredator, this.visionRadiusPredator, this.initialPopulationPredator); this._preyParameters = new GroupParameters(this.reproductionPrey, this.maxSpeedPrey, this.visionRadiusPrey, this.initialPopulationPrey); //Initialize the ecosystem Resource plants = new Resource(initialPlants, growthRate, threshold); Debug.Log(initialPlants); Debug.Log(threshold); this._ecosystem = new Ecosystem(this._preyParameters, this._predatorParameters, plants, iterations, agents, strategy); //Initialize the view this._myView = Instantiate(MyView); this._myView.Initialize(this._preyParameters.GroupSize, this._predatorParameters.GroupSize); this.CalculateTotalSimulations(); this.PATH = Application.dataPath + "/SimulationData/SimulationDataPhase2/"; Debug.Log(this.PATH); this.CreateFileForSimulation(); } //If we haven't completed the number of iterations fixed or there is no animal group extinguised we keep on the loop if (this._ecosystem.Iteration < ITERATIONS_PER_SIMULATION & !this._ecosystem.Extinguised) { //If the ecosystem has resseted (the iteration has finished), then we reset the view and save the data in the file if (this._ecosystem.Reset) { this.UpdateFile(); this._ecosystem.Update(); this.ResetView(); } //If not we update the ecosystem (the next step/frame of the iteration) else { //Update the model this._ecosystem.Update(); //Pass the information of positions from model to view List <Vector3> preyModelPositions = this.TransformToVector3(this._ecosystem.GetPreyPositions()); List <Vector3> predatorModelPositions = this.TransformToVector3(this._ecosystem.GetPredatorPositions()); this._myView.UpdatePositions(preyModelPositions, predatorModelPositions); } } //If the simulation has finished, we start another one if necessary else if (this._simulationCounter < this.NUMBER_OF_SIMULATIONS) { this._simulationCounter++; this._totalSimulations += 1; Debug.Log("Simulación " + this._simulationCounter); //Initialize the ecosystem Resource plants = new Resource(initialPlants, growthRate, threshold); this._ecosystem = new Ecosystem(this._preyParameters, this._predatorParameters, plants, iterations, agents, strategy); //Reset the view this.ResetView(); //Create a new file to save the data of the simulation this.CreateFileForSimulation(); } else { Debug.Log("Fin de las simulaciones"); Destroy(this.gameObject); } } }//End Update
public PreyBuilder(GroupParameters parameters) : base(parameters) { }
public PredatorBuilder(GroupParameters parameters, int iterations, int candidates, int strategy) : base(parameters) { this.iterations = iterations; this.candidates = candidates; this.strategy = strategy; }
public AnimalBuilder(GroupParameters parameters) { this._animalParameters = parameters; this._creationCounter = 0; }