public void RentalsPilot(int id, string user, decimal expense) { var pilot = dbContext.RallyPilots.Where(x => x.Id == id).FirstOrDefault(); var team = dbContext.Teams.Where(x => x.User == user).FirstOrDefault(); pilot.TeamId = team.Id; team.RallyPilotId = id; money.ExpenseAccountAsync(expense, user); }
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("Ремонта, бе извършен успешно"); }