Exemple #1
0
        public async Task Delete(int id)
        {
            await CheckPermission();

            var sqlR = new ChangedPlanedInspectionRoutesRepository(_logger);
            await sqlR.Delete(id);
        }
Exemple #2
0
        public async Task <JsonResult> GetAll(int skip, int limit, string filter = null)
        {
            await CheckPermission();

            var sqlR   = new ChangedPlanedInspectionRoutesRepository(_logger);
            var result = await sqlR.GetAll(skip, limit, filter);

            return(Json(result));
        }
Exemple #3
0
        public async Task <JsonResult> AddOrUpdate([FromBody] ChangedPlanedInspectionRoute input)
        {
            await CheckPermission();

            var sqlR = new ChangedPlanedInspectionRoutesRepository(_logger);

            if (input.Id == 0)
            {
                return(Json(await sqlR.Add(input)));
            }
            return(Json(await sqlR.Update(input)));
        }
Exemple #4
0
        /// <summary>
        /// То2 таблица
        /// </summary>
        private static async Task <ChangedTo2OrCtoDto> GetTo2OrCto(GetRouteInformationTableRequest input, ILogger logger)
        {
            var sqlRPlaneInspections   = new PlanedInspectionRoutesRepository(logger);
            var sqlRChangedInspections = new ChangedPlanedInspectionRoutesRepository(logger);

            var planedInspection = await sqlRPlaneInspections.ById(input.EntityId);

            var changedInspection = await sqlRChangedInspections.ByPlanedInspectionRouteId(planedInspection.Id);

            var sqlRTrains            = new TrainRepository(logger);
            var sqlRPlanedRouteTrains = new PlanedRouteTrainsRepository(logger);
            var sqlRRoute             = new RoutesRepository(logger);

            var planedRouteTrain = await sqlRPlanedRouteTrains.ById(input.PlanedRouteTrainId);

            var route = await sqlRRoute.ById(planedRouteTrain.RouteId);

            var train = await sqlRTrains.ById(planedRouteTrain.TrainId);


            var result = new ChangedTo2OrCtoDto
            {
                Id        = planedInspection.Id,
                RouteName = route.Name,
                TrainName = train.Name,
                Plan      = new ChangedTo2OrCtoDto.Planned
                {
                    DateStart = planedInspection.Start.ToFuckingGenaFormat(planedRouteTrain.Date),
                    DateEnd   = planedInspection.End.ToFuckingGenaFormat(planedRouteTrain.Date)
                },
                Fact = new ChangedTo2OrCtoDto.Actual
                {
                    DateStart = planedInspection.Start.ToFuckingGenaFormat(planedRouteTrain.Date),
                    DateEnd   = planedInspection.End.ToFuckingGenaFormat(planedRouteTrain.Date),
                    Canseled  = false
                }
            };

            if (changedInspection != null)
            {
                result.Fact.DateStart = changedInspection.Start.ToFuckingGenaFormat(planedRouteTrain.Date);
                result.Fact.DateEnd   = changedInspection.End.ToFuckingGenaFormat(planedRouteTrain.Date);
                if (changedInspection.Droped)
                {
                    result.Fact.Canseled = changedInspection.Droped;
                }
            }

            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();
            }
        }