public async Task Delete(int id) { await CheckPermission(); var sqlR = new ChangePlaneBrigadeTrainsRepository(_logger); await sqlR.Delete(id); }
public async Task <JsonResult> GetAll(int skip, int limit, string filter = null) { await CheckPermission(); var sqlR = new ChangePlaneBrigadeTrainsRepository(_logger); var result = await sqlR.GetAll(skip, limit, filter); return(Json(result)); }
public async Task <JsonResult> AddOrUpdate([FromBody] ChangePlaneBrigadeTrain input) { await CheckPermission(); var sqlR = new ChangePlaneBrigadeTrainsRepository(_logger); if (input.Id == 0) { return(Json(await sqlR.Add(input))); } return(Json(await sqlR.Update(input))); }
/// <summary> /// Данные по ебучим юзерам меж станками /// </summary> private static async Task GetPlanedBrigadesData(int planedRouteTrainId, RouteData result, ILogger logger) { var sqlRPlanedStations = new PlanedStationOnTripsRepository(logger); var sqlRUsers = new UserRepository(logger); var sqlRStations = new StantionsRepository(logger); var sqlRPlaneBrigadeTrains = new PlaneBrigadeTrainsRepository(logger); var sqlRChangedBrigadeTrains = new ChangePlaneBrigadeTrainsRepository(logger); result.PlaneRoute.UserOnStations = new List <PlanedUserOnStations>(); var planeBrigades = await sqlRPlaneBrigadeTrains.ByPlanedRouteTrainId(planedRouteTrainId); foreach (var planeBrigade in planeBrigades) { var stationStartId = (await sqlRPlanedStations.ById(planeBrigade.StantionStartId)).StantionId; var stationEndId = (await sqlRPlanedStations.ById(planeBrigade.StantionEndId)).StantionId; var changedBrigadeData = await sqlRChangedBrigadeTrains.ByPlaneBrigadeTrainId(planeBrigade.Id); var toAdd = new PlanedUserOnStations { PlaneBrigadeTrainId = planeBrigade.Id, UserName = (await sqlRUsers.ById(planeBrigade.UserId)).Name, StationStartName = (await sqlRStations.ById(stationStartId)).Name, StationEndName = (await sqlRStations.ById(stationEndId)).Name, ChangeBrigadeTrainId = changedBrigadeData?.Id }; if (changedBrigadeData != null) { toAdd.ChangedUserName = (await sqlRUsers.ById(planeBrigade.UserId)).Name; toAdd.ChangedStationStartName = (await sqlRStations.ById(changedBrigadeData.StantionEndId)).Name; toAdd.ChangedStationEndName = (await sqlRStations.ById(changedBrigadeData.StantionStartId)).Name; } result.PlaneRoute.UserOnStations.Add(toAdd); } }
/// <summary> /// Бригады таблица /// </summary> private static async Task <ChangeTimeRangeBrigadeDto> GetBrigadeData(GetRouteInformationTableRequest input, ILogger logger) { var sqlRPlanedRouteTrains = new PlanedRouteTrainsRepository(logger); var sqlRTrips = new TripsRepository(logger); var sqlRPlanedStations = new PlanedStationOnTripsRepository(logger); var sqlRUsers = new UserRepository(logger); var sqlRStations = new StantionsRepository(logger); var sqlRPlaneBrigadeTrains = new PlaneBrigadeTrainsRepository(logger); var sqlRChangedBrigadeTrains = new ChangePlaneBrigadeTrainsRepository(logger); //var result = new ReportResponse { Rows = new List<Row>() }; var stationsSimple = new List <StantionSimple>(); //Берем всех юзерков var users = await sqlRUsers.GetAll(); //Получим все станки с маршрута var planeStations = await sqlRPlanedStations.ByPlannedRouteTrainId(input.PlanedRouteTrainId); planeStations.OrderBy(x => x.InTime); var currentTripId = 0; for (var index = 0; index < planeStations.Count; index++) { var planeStation = planeStations[index]; var trip = await sqlRTrips.ById(planeStation.TripId); var station = await sqlRStations.ById(planeStation.StantionId); var qqStart = planeStation.InTime.ToStringTimeOnly(); var qqEnd = planeStation.OutTime.ToStringTimeOnly(); if (currentTripId == 0 || planeStation.TripId != currentTripId) { qqStart = "н/д"; } if (index != planeStations.Count - 1) { if (planeStations[index + 1].TripId != planeStation.TripId && currentTripId != 0) { qqEnd = "н/д"; } } else { qqEnd = "н/д"; } var qq1 = $"{station.Name} {qqStart}-{qqEnd} ({trip.Name})"; stationsSimple.Add(new StantionSimple { StantionId = planeStation.Id, StantionName = qq1, TripName = trip.Name, InTime = planeStation.InTime }); currentTripId = planeStation.TripId; } var planeBrigades = await sqlRPlaneBrigadeTrains.ByPlanedRouteTrainId(input.PlanedRouteTrainId); planeBrigades = planeBrigades.Where(x => x.StantionStartId == input.EntityId).ToList(); var result = new ChangeTimeRangeBrigadeDto { Users = new List <ChangeTimeRangeUserDto>(), DataSource = new DataSource { Stantions = stationsSimple .OrderBy(x => x.TripName).ThenBy(y => y.InTime) .Select(x => new DataSourceDto { Value = x.StantionId, Text = x.StantionName }) .ToList(), Users = users .OrderBy(x => x.Name) .Select(x => new DataSourceDto { Value = x.Id, Text = x.Name }) .ToList() } }; foreach (var planeBrigade in planeBrigades) { var changeBrigade = await sqlRChangedBrigadeTrains.ByPlaneBrigadeTrainId(planeBrigade.Id) ?? new ChangePlaneBrigadeTrain { StantionEndId = 0, StantionStartId = 0, Droped = false, UserId = 0 }; var planeStartStation = await sqlRPlanedStations.ById(planeBrigade.StantionStartId); var planeEndStation = await sqlRPlanedStations.ById(planeBrigade.StantionEndId); var realStartStation = await sqlRStations.ById(planeStartStation.StantionId); var realEndStation = await sqlRStations.ById(planeEndStation.StantionId); var planedUser = await sqlRUsers.ById(planeBrigade.UserId); var toAdd = new ChangeTimeRangeUserDto { StartId = planeStartStation.Id, EndId = planeEndStation.Id, UserId = planedUser.Id, User = planedUser.Name, Start = realStartStation.Name, End = realEndStation.Name, PlaneBrigadeTrainId = planeBrigade.Id, Canseled = changeBrigade.Droped }; if (changeBrigade.UserId != 0) { toAdd.UserId = changeBrigade.UserId; } if (changeBrigade.StantionEndId != 0) { toAdd.EndId = changeBrigade.StantionEndId; } if (changeBrigade.StantionStartId != 0) { toAdd.StartId = changeBrigade.StantionStartId; } result.Users.Add(toAdd); } return(result); }
public async Task DeleteFromPlanedRouteTrains(int planedRouteTrainsId) { using (var transaction = new TransactionScope(asyncFlowOption: TransactionScopeAsyncFlowOption.Enabled)) { var sqlRPlanedInspectionOnRoutes = new PlanedInspectionRoutesRepository(_logger); var sqlRPlaneStations = new PlanedStationOnTripsRepository(_logger); var sqlRPlaneBrigades = new PlaneBrigadeTrainsRepository(_logger); var sqlRPlanedRouteTrains = new PlanedRouteTrainsRepository(_logger); var sqlRChangedInspections = new ChangedPlanedInspectionRoutesRepository(_logger); var sqlRChangedBrigades = new ChangePlaneBrigadeTrainsRepository(_logger); var sqlRChangedStations = new ChangePlaneStantionOnTripsRepository(_logger); //ебаем нахуй инспекции var planedInspections = await sqlRPlanedInspectionOnRoutes.ByPlanedRouteTrainId(planedRouteTrainsId); foreach (var planedInspection in planedInspections) { //Блядь чистим изменненые к хуям. var changed = await sqlRChangedInspections.ByPlanedInspectionRouteId(planedInspection.Id); if (changed != null) { await sqlRChangedInspections.Delete(changed.Id); } await sqlRPlanedInspectionOnRoutes.Delete(planedInspection.Id); } //Ебаем юзеров к хуям var planeBrigades = await sqlRPlaneBrigades.ByPlanedRouteTrainId(planedRouteTrainsId); foreach (var planeBrigade in planeBrigades) { //Блядь чистим изменненые к хуям. var changed = await sqlRChangedBrigades.ByPlaneBrigadeTrainId(planeBrigade.Id); if (changed != null) { await sqlRChangedBrigades.Delete(changed.Id); } await sqlRPlaneBrigades.Delete(planeBrigade.Id); } //ебаем станки var planeStations = await sqlRPlaneStations.ByPlannedRouteTrainId(planedRouteTrainsId); foreach (var planeStation in planeStations) { //Блядь чистим изменненые к хуям. var changed = await sqlRChangedStations.ByPlaneStantionOnTripId(planeStation.Id); if (changed != null) { await sqlRChangedStations.Delete(changed.Id); } await sqlRPlaneStations.Delete(planeStation.Id); } //Ну и главную хуету нахуй await sqlRPlanedRouteTrains.Delete(planedRouteTrainsId); transaction.Complete(); } }