Пример #1
0
        public async Task CreateTeamAsync(string text, string user)
        {
            var numberMoney     = money.FindIdMoneyAccountAsync(user);
            var numberPilot     = pilot.CreateRallyPilotsAsync();
            var numberNavigator = navigator.CreateRallyNavigatorsAsync();
            var numberCar       = car.CreateCarsAsync().Result;
            var newTeam         = dbContext.Teams.Add(new Team
            {
                Name             = text,
                User             = user,
                MoneyAccountId   = numberMoney,
                RallyPilotId     = numberPilot,
                RallyNavigatorId = numberNavigator,
                CarId            = numberCar,
            });

            dbContext.SaveChanges();
            var addCarId       = car.GetCar(numberCar).Result;
            var addPilotId     = pilot.GetPilot(numberPilot);
            var addNavigatorId = navigator.GetNavigator(numberNavigator);

            addCarId.TeamId       = newTeam.Entity.Id;
            addPilotId.TeamId     = newTeam.Entity.Id;
            addNavigatorId.TeamId = newTeam.Entity.Id;
            await dbContext.SaveChangesAsync();
        }
Пример #2
0
        public async Task <string> DeletePilots(int id)
        {
            var runway = pilots.GetPilot(id);

            runway.IsDeleted = true;
            await dbContext.SaveChangesAsync();

            return("Пилота, е изтрит успешно.");
        }
Пример #3
0
        public async Task <string> EditPilot(PilotViewModels newPilot)
        {
            var oldPilot = pilots.GetPilot(newPilot.Id);

            oldPilot.FirstName        = newPilot.FirstName;
            oldPilot.LastName         = newPilot.LastName;
            oldPilot.Age              = newPilot.Age;
            oldPilot.Salary           = newPilot.Salary;
            oldPilot.Concentration    = newPilot.Concentration;
            oldPilot.Devotion         = newPilot.Devotion;
            oldPilot.Reflexes         = newPilot.Reflexes;
            oldPilot.Energy           = newPilot.Energy;
            oldPilot.Experience       = newPilot.Experience;
            oldPilot.PhysicalTraining = newPilot.PhysicalTraining;
            oldPilot.Pounds           = newPilot.Pounds;
            await dbContext.SaveChangesAsync();

            return("Пилота, е променен успешно.");
        }
Пример #4
0
        public async Task <IActionResult> EditPilot(int id)
        {
            _logger.LogInformation("admin view edit pilot");
            var pilot     = pilots.GetPilot(id);
            var viewModel = new PilotViewModels
            {
                Id               = pilot.Id,
                FirstName        = pilot.FirstName,
                LastName         = pilot.LastName,
                Age              = pilot.Age,
                Salary           = pilot.Salary,
                Concentration    = pilot.Concentration,
                Devotion         = pilot.Devotion,
                Reflexes         = pilot.Reflexes,
                Energy           = pilot.Energy,
                Experience       = pilot.Experience,
                PhysicalTraining = pilot.PhysicalTraining,
                Pounds           = pilot.Pounds,
            };

            return(this.View(viewModel));
        }