private static int DeleteRecordsByController(Controller controller) { int ret = 0; using (TransactionalDbClient tc = ionixFactory.CreateTransactionalDbClient()) { ControllerRepository controllerRepository = new ControllerRepository(tc.Cmd); ActionRepository actionRepository = new ActionRepository(tc.Cmd); List <Server.Models.Action> controllerActions = actionRepository.SelectByControllerId(controller.Id).ToList(); if (!controllerActions.IsEmptyList()) { List <int> controllerActionIds = new List <int>(controllerActions.Count); controllerActions.ForEach((aa) => controllerActionIds.Add(aa.Id)); //RoleControllerAction Siliniyor. RoleActionRepository roleControllerActionRepository = new RoleActionRepository(tc.Cmd); ret += roleControllerActionRepository.DeleteByControllerActionIds(controllerActionIds); //controllerAction Siliniyor. ret += actionRepository.DeleteByControllerId(controller.Id); } //controller Siliniyor. ret += controllerRepository.Delete(controller); tc.Commit(); } return(ret); }
private static int DeleteRecordsByController(Controller controller) { int ret = 0; using (TransactionalDbClient tc = DataFactory.CreateTransactionalDbClient()) { ControllerRepository controllerRepository = new ControllerRepository(tc.Cmd); ActionRepository actionRepository = new ActionRepository(tc.Cmd); List<Models.Action> controllerActions = actionRepository.SelectByControllerId(controller.Id).ToList(); if (!controllerActions.IsEmptyList()) { List<int> controllerActionIds = new List<int>(controllerActions.Count); controllerActions.ForEach((aa) => controllerActionIds.Add(aa.Id)); //RoleControllerAction Siliniyor. RoleActionRepository roleControllerActionRepository = new RoleActionRepository(tc.Cmd); ret += roleControllerActionRepository.DeleteByControllerActionIds(controllerActionIds); //controllerAction Siliniyor. ret += actionRepository.DeleteByControllerId(controller.Id); } //controller Siliniyor. ret += controllerRepository.Delete(controller); tc.Commit(); } return ret; }