예제 #1
0
        private void AddButton_Click(object sender, EventArgs e)
        {
            string varName = VarNameTxt.Text;

            ResearchForm.AddIgnore(varName);
            Close();
        }
        public async Task <IActionResult> Edit([FromRoute] int id, [FromServices] ResearchPermissionsService permissionsService)
        {
            var item = await _db.GetResearchAsync(id);

            if (item == null)
            {
                return(NotFound(new ApiError("404", "Not Found", $"Исследование #{id} не найдено")));
            }

            var personId    = Int32.Parse(User?.Claims.FirstOrDefault(x => x.Type == ClaimTypes.PrimarySid)?.Value);
            var permissions = permissionsService.Get(item, personId);

            if (!permissions.CanRead)
            {
                return(Forbid());
            }

            var model = new ResearchForm
            {
                Id       = item.Id,
                Research = item,
                Init     = new ResearchInitForm
                {
                    Name        = item.Name,
                    Description = item.Description,
                    AlgorithmId = item.AlgorithmId,
                    DataSetId   = item.DataSetId,
                    CreatorId   = item.CreatorId,
                    ExecutorId  = item.ExecutorId,
                },
                Calculated = item.AccuracyRates != null && item.EfficiencyRates != null ?
                             new ResearchCalculatedForm
                {
                    AccuracyRates   = item.AccuracyRates,
                    EfficiencyRates = item.EfficiencyRates
                } : null,
                Algorithms  = await _db.GetAlgorithmsListItemsAsync(),
                DataSets    = await _db.GetDataSetsListItemsAsync(),
                Executors   = await _db.GetPersonsListItemsByRoleAsync("User"),
                Permissions = permissions
            };

            return(Ok(model));
        }
예제 #3
0
        public ActionResult Edit(ResearchForm form)
        {
            Debug.WriteLine(string.Format("POST: Research Controller: Edit - researchID={0}", form.ID));
            var game = GameState.Game;

            DB_research research = game.GameStatistics.Research.Find(x => x.id == form.ID);

            if (research.game_id == null || research.game_id != game.Info.id)
            {
                return(RedirectToRoute("game", new { gameID = game.Info.id }));
            }

            research.name        = form.Name;
            research.description = form.Description;
            research.rp_cost     = form.RPCost;

            research.apply_military       = form.ApplyMilitary;
            research.apply_units          = form.ApplyUnits;
            research.apply_ships          = form.ApplyShips;
            research.apply_infrastructure = form.ApplyInfrastructure;

            research.domestic_influence_bonus = form.DomesticInfluence;
            research.foreign_influence_bonus  = form.ForeignInfluence;

            research.health_bonus         = form.HealthBonus;
            research.regeneration_bonus   = form.RegenerationBonus;
            research.attack_bonus         = form.AttackBonus;
            research.special_attack_bonus = form.SpecialAttackBonus;
            research.agility_bonus        = form.AgilityBonus;

            research.science_bonus = form.ScienceBonus;
            research.colonial_development_bonus = form.ColonialDevelopmentBonus;
            research.ship_construction_bonus    = form.ShipConstructionBonus;
            research.unit_training_bonus        = form.UnitTrainingBonus;
            research.gmnotes = form.GMNotes;
            Database.Session.Update(research);

            Database.Session.Flush();
            return(RedirectToRoute("Statistics"));
        }
        public async Task <IActionResult> Create()
        {
            var model = new ResearchForm
            {
                Id          = 0,
                Research    = new Research(),
                Init        = new ResearchInitForm(),
                Calculated  = null,
                Algorithms  = await _db.GetAlgorithmsListItemsAsync(),
                DataSets    = await _db.GetDataSetsListItemsAsync(),
                Executors   = await _db.GetPersonsListItemsByRoleAsync("User"),
                Permissions = new ResearchPermissions
                {
                    StatusChangeOptions = new ResearchStatus[] { ResearchStatus.ASSIGNED },
                    CanEditInit         = true,
                    CanEditCalculated   = false,
                    CanPostComment      = false
                }
            };

            return(Ok(model));
        }