Пример #1
0
        public async Task <IActionResult> Training(string sessionType, string type)
        {
            _logger.LogInformation("Training");
            var inputSessionType = sessionType.Split().ToArray();
            var typeTreining     = inputSessionType[0];
            int money            = int.Parse(inputSessionType[1]);

            var input = type.Split().ToArray();

            type = input[0];
            int id   = int.Parse(input[1]);
            var text = string.Empty;

            if (type == "Pilot" && (pilot.IsItBusy(id) == true))
            {
                text = "Пилота, вече е тренирал или е зает с друга дейност.";
                return(this.RedirectToAction($"{type}", "Teams", new { input = text }));
            }
            else if (type == "Navigator" && (navigator.IsItBusy(id) == true))
            {
                text = "Навигатора, вече е тренирал или е зает с друга дейност.";
                return(this.RedirectToAction($"{type}", "Teams", new { input = text }));
            }

            training.Training(id, typeTreining, type);
            this.money.ExpenseAccountAsync(money, User.Identity.Name);

            text = "Тренировката бе извършена успешно.";
            return(this.RedirectToAction($"{type}", "Teams", new { input = text }));
        }
Пример #2
0
        public async Task <string> Repair(string type, int id, decimal price, string user)
        {
            var team = await dbContext.Teams.Where(x => x.User == user).FirstOrDefaultAsync();

            if ((team.RallyPilotId ?? 0) == 0)
            {
                ;
            }
            if ((team.RallyNavigatorId ?? 0) == 0)
            {
                ;
            }

            var idPilot     = team.RallyPilotId.Value;
            var idNavigator = team.RallyNavigatorId.Value;

            var pilot     = rallyPilots.IsItBusy(idPilot);
            var navigator = rallyNavigators.IsItBusy(idNavigator);

            if ((pilot || navigator))
            {
                return("Пилота и навигатора извършват друга работа.");
            }

            if (type == "Aerodynamics")
            {
                var typeParts = await dbContext.Aerodynamics.Where(x => x.Id == id).FirstOrDefaultAsync();

                if (typeParts.Strength == 100)
                {
                    return("Часта е напълно здрава.");
                }
                RepairParts(typeParts, rallyPilots, idPilot, rallyNavigators, idNavigator).GetAwaiter();;
            }
            else if (type == "Brakes")
            {
                var typeParts = await dbContext.Brakes.Where(x => x.Id == id).FirstOrDefaultAsync();

                if (typeParts.Strength == 100)
                {
                    return("Часта е напълно здрава.");
                }
                RepairParts(typeParts, rallyPilots, idPilot, rallyNavigators, idNavigator).GetAwaiter();;
            }
            else if (type == "Engines")
            {
                var typeParts = await dbContext.Engines.Where(x => x.Id == id).FirstOrDefaultAsync();

                if (typeParts.Strength == 100)
                {
                    return("Часта е напълно здрава.");
                }
                RepairParts(typeParts, rallyPilots, idPilot, rallyNavigators, idNavigator).GetAwaiter();;
            }
            else if (type == "Gearboxs")
            {
                var typeParts = await dbContext.Gearboxs.Where(x => x.Id == id).FirstOrDefaultAsync();

                if (typeParts.Strength == 100)
                {
                    return("Часта е напълно здрава.");
                }
                RepairParts(typeParts, rallyPilots, idPilot, rallyNavigators, idNavigator).GetAwaiter();;
            }
            else if (type == "ModelsCars")
            {
                var typeParts = await dbContext.ModelsCars.Where(x => x.Id == id).FirstOrDefaultAsync();

                if (typeParts.Strength == 100)
                {
                    return("Часта е напълно здрава.");
                }
                RepairParts(typeParts, rallyPilots, idPilot, rallyNavigators, idNavigator).GetAwaiter();;
            }
            else if (type == "Mountings")
            {
                var typeParts = await dbContext.Mountings.Where(x => x.Id == id).FirstOrDefaultAsync();

                if (typeParts.Strength == 100)
                {
                    return("Часта е напълно здрава.");
                }
                RepairParts(typeParts, rallyPilots, idPilot, rallyNavigators, idNavigator).GetAwaiter();;
            }
            else if (type == "Turbo")
            {
                var typeParts = await dbContext.Turbos.Where(x => x.Id == id).FirstOrDefaultAsync();

                if (typeParts.Strength == 100)
                {
                    return("Часта е напълно здрава.");
                }
                RepairParts(typeParts, rallyPilots, idPilot, rallyNavigators, idNavigator).GetAwaiter();;
            }

            money.ExpenseAccountAsync(price, user);
            await dbContext.SaveChangesAsync();

            return("Ремонта, бе извършен успешно");
        }