Пример #1
0
        public async Task <IActionResult> StrategyCreate(int id = 0)
        {
            var tyres = await _tyreStrats.GetTyres(true);

            var strategy = await _tyreStrats.GetStrategyById(id, true);

            if (strategy is null)
            {
                var viewmodel = new CreateStrategyModel(0, 0, null, tyres);
                return(View(viewmodel));
            }
            else
            {
                var viewmodel = new CreateStrategyModel(strategy.StrategyId, strategy.RaceLen, strategy.Tyres, tyres);
                return(View(viewmodel));
            }
        }
Пример #2
0
 public ActionResult Create(CreateStrategyModel model)
 {
     if (ModelState.IsValid)
     {
         try
         {
             StrategyToken token = _strategyService.Create(new StrategyToken {
                 name = model.Name, owner = "<Authenticated User>"
             });
             return(RedirectToAction("Edit", new { id = token.id }));
         }
         catch (Exception ex)
         {
             ModelState.AddModelError("", ex);
         }
     }
     return(View(model));
 }