Exemplo n.º 1
0
        public async Task Delete(int id)
        {
            await CheckPermission();

            var sqlR = new ChangedPlanedInspectionRoutesRepository(_logger);
            await sqlR.Delete(id);
        }
        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();
            }
        }