Exemplo n.º 1
0
        public void DeleteActionProposeds(List <int> actionProposedIDsToDelete)
        {
            //Validate Input
            foreach (int actionProposedID in actionProposedIDsToDelete)
            {
                if (actionProposedID.IsInvalidKey())
                {
                    BusinessLayerHelper.ThrowErrorForInvalidDataKey("ActionProposedID");
                }
            }

            List <ActionProposed> actionProposedsToBeDeleted = new List <ActionProposed>();

            foreach (int actionProposedID in actionProposedIDsToDelete)
            {
                ActionProposed actionProposed = new ActionProposed {
                    ActionProposedID = actionProposedID
                };
                _DatabaseContext.ActionProposeds.Attach(actionProposed);
                _DatabaseContext.ActionProposeds.DeleteObject(actionProposed);
                actionProposedsToBeDeleted.Add(actionProposed);
                OnActionProposedDeleting(actionProposed);
            }

            int numberOfAffectedRows = _DatabaseContext.SaveChanges();

            if (numberOfAffectedRows != actionProposedIDsToDelete.Count)
            {
                throw new DataNotUpdatedException("One or more actionProposed records have not been deleted.");
            }
            foreach (ActionProposed actionProposedToBeDeleted in actionProposedsToBeDeleted)
            {
                OnActionProposedDeleted(actionProposedToBeDeleted);
            }
        }
        public void DeleteTermsAndConditions(List <int> termsAndConditionsIDsToDelete)
        {
            //Validate Input
            foreach (int termsAndConditionsID in termsAndConditionsIDsToDelete)
            {
                if (termsAndConditionsID.IsInvalidKey())
                {
                    BusinessLayerHelper.ThrowErrorForInvalidDataKey("TermsAndConditionsID");
                }
            }

            List <TermsAndCondition> termsAndConditionsToBeDeleted = new List <TermsAndCondition>();

            foreach (int termsAndConditionsID in termsAndConditionsIDsToDelete)
            {
                TermsAndCondition termsAndCondition = new TermsAndCondition {
                    TermsAndConditionsID = termsAndConditionsID
                };
                _DatabaseContext.TermsAndConditions.Attach(termsAndCondition);
                _DatabaseContext.TermsAndConditions.DeleteObject(termsAndCondition);
                termsAndConditionsToBeDeleted.Add(termsAndCondition);
                OnTermsAndConditionDeleting(termsAndCondition);
            }

            int numberOfAffectedRows = _DatabaseContext.SaveChanges();

            if (numberOfAffectedRows != termsAndConditionsIDsToDelete.Count)
            {
                throw new DataNotUpdatedException("One or more termsAndCondition records have not been deleted.");
            }
            foreach (TermsAndCondition termsAndConditionToBeDeleted in termsAndConditionsToBeDeleted)
            {
                OnTermsAndConditionDeleted(termsAndConditionToBeDeleted);
            }
        }
Exemplo n.º 3
0
        public void DeleteScientificName(ScientificName scientificNameToBeDeleted)
        {
            //Validate Input
            if (scientificNameToBeDeleted == null)
            {
                throw (new ArgumentNullException("scientificNameToBeDeleted"));
            }

            // Validate Primary key value
            if (scientificNameToBeDeleted.ScientificNameID.IsInvalidKey())
            {
                BusinessLayerHelper.ThrowErrorForInvalidDataKey("ScientificNameID");
            }

            OnScientificNameSaving(scientificNameToBeDeleted);
            OnScientificNameDeleting(scientificNameToBeDeleted);

            if (scientificNameToBeDeleted.EntityState == EntityState.Detached)
            {
                _DatabaseContext.ScientificNames.Attach(scientificNameToBeDeleted);
            }
            _DatabaseContext.ScientificNames.DeleteObject(scientificNameToBeDeleted);
            int numberOfAffectedRows = _DatabaseContext.SaveChanges();

            if (numberOfAffectedRows == 0)
            {
                throw new DataNotUpdatedException("No ScientificName deleted!");
            }

            OnScientificNameDeleted(scientificNameToBeDeleted);
            OnScientificNameSaved(scientificNameToBeDeleted);
        }
Exemplo n.º 4
0
        public void DeleteProjects(List <int> projectIDsToDelete)
        {
            //Validate Input
            foreach (int projectID in projectIDsToDelete)
            {
                if (projectID.IsInvalidKey())
                {
                    BusinessLayerHelper.ThrowErrorForInvalidDataKey("ProjectID");
                }
            }

            List <Project> projectsToBeDeleted = new List <Project>();

            foreach (int projectID in projectIDsToDelete)
            {
                Project project = new Project {
                    ProjectID = projectID
                };
                _DatabaseContext.Projects.Attach(project);
                _DatabaseContext.Projects.DeleteObject(project);
                projectsToBeDeleted.Add(project);
                OnProjectDeleting(project);
            }

            int numberOfAffectedRows = _DatabaseContext.SaveChanges();

            if (numberOfAffectedRows != projectIDsToDelete.Count)
            {
                throw new DataNotUpdatedException("One or more project records have not been deleted.");
            }
            foreach (Project projectToBeDeleted in projectsToBeDeleted)
            {
                OnProjectDeleted(projectToBeDeleted);
            }
        }
Exemplo n.º 5
0
        public void DeleteDevices(List <int> deviceIDsToDelete)
        {
            //Validate Input
            foreach (int deviceID in deviceIDsToDelete)
            {
                if (deviceID.IsInvalidKey())
                {
                    BusinessLayerHelper.ThrowErrorForInvalidDataKey("DeviceID");
                }
            }

            List <Device> devicesToBeDeleted = new List <Device>();

            foreach (int deviceID in deviceIDsToDelete)
            {
                Device device = new Device {
                    DeviceID = deviceID
                };
                _DatabaseContext.Devices.Attach(device);
                _DatabaseContext.Devices.DeleteObject(device);
                devicesToBeDeleted.Add(device);
                OnDeviceDeleting(device);
            }

            int numberOfAffectedRows = _DatabaseContext.SaveChanges();

            if (numberOfAffectedRows != deviceIDsToDelete.Count)
            {
                throw new DataNotUpdatedException("One or more device records have not been deleted.");
            }
            foreach (Device deviceToBeDeleted in devicesToBeDeleted)
            {
                OnDeviceDeleted(deviceToBeDeleted);
            }
        }
Exemplo n.º 6
0
        public void DeleteReps(List <int> repIDsToDelete)
        {
            //Validate Input
            foreach (int repID in repIDsToDelete)
            {
                if (repID.IsInvalidKey())
                {
                    BusinessLayerHelper.ThrowErrorForInvalidDataKey("RepID");
                }
            }

            List <Rep> repsToBeDeleted = new List <Rep>();

            foreach (int repID in repIDsToDelete)
            {
                Rep rep = new Rep {
                    RepID = repID
                };
                _DatabaseContext.Reps.Attach(rep);
                _DatabaseContext.Reps.DeleteObject(rep);
                repsToBeDeleted.Add(rep);
                OnRepDeleting(rep);
            }

            int numberOfAffectedRows = _DatabaseContext.SaveChanges();

            if (numberOfAffectedRows != repIDsToDelete.Count)
            {
                throw new DataNotUpdatedException("One or more rep records have not been deleted.");
            }
            foreach (Rep repToBeDeleted in repsToBeDeleted)
            {
                OnRepDeleted(repToBeDeleted);
            }
        }
Exemplo n.º 7
0
        public void DeleteOrganisms(List <int> organismIDsToDelete)
        {
            //Validate Input
            foreach (int organismID in organismIDsToDelete)
            {
                if (organismID.IsInvalidKey())
                {
                    BusinessLayerHelper.ThrowErrorForInvalidDataKey("OrganismID");
                }
            }

            List <Organism> organismsToBeDeleted = new List <Organism>();

            foreach (int organismID in organismIDsToDelete)
            {
                Organism organism = new Organism {
                    OrganismID = organismID
                };
                _DatabaseContext.Organisms.Attach(organism);
                _DatabaseContext.Organisms.DeleteObject(organism);
                organismsToBeDeleted.Add(organism);
                OnOrganismDeleting(organism);
            }

            int numberOfAffectedRows = _DatabaseContext.SaveChanges();

            if (numberOfAffectedRows != organismIDsToDelete.Count)
            {
                throw new DataNotUpdatedException("One or more organism records have not been deleted.");
            }
            foreach (Organism organismToBeDeleted in organismsToBeDeleted)
            {
                OnOrganismDeleted(organismToBeDeleted);
            }
        }
Exemplo n.º 8
0
        public void DeleteUsers(List <Guid> userIDsToDelete)
        {
            //Validate Input
            foreach (Guid userID in userIDsToDelete)
            {
                if (userID.IsInvalidKey())
                {
                    BusinessLayerHelper.ThrowErrorForInvalidDataKey("UserID");
                }
            }

            List <User> usersToBeDeleted = new List <User>();

            foreach (Guid userID in userIDsToDelete)
            {
                User user = new User {
                    UserID = userID
                };
                _DatabaseContext.Users.Attach(user);
                _DatabaseContext.Users.DeleteObject(user);
                usersToBeDeleted.Add(user);
                OnUserDeleting(user);
            }

            int numberOfAffectedRows = _DatabaseContext.SaveChanges();

            if (numberOfAffectedRows != userIDsToDelete.Count)
            {
                throw new DataNotUpdatedException("One or more user records have not been deleted.");
            }
            foreach (User userToBeDeleted in usersToBeDeleted)
            {
                OnUserDeleted(userToBeDeleted);
            }
        }
Exemplo n.º 9
0
        public void DeleteGroups(List <int> groupIDsToDelete)
        {
            //Validate Input
            foreach (int groupID in groupIDsToDelete)
            {
                if (groupID.IsInvalidKey())
                {
                    BusinessLayerHelper.ThrowErrorForInvalidDataKey("GroupID");
                }
            }

            List <Group> groupsToBeDeleted = new List <Group>();

            foreach (int groupID in groupIDsToDelete)
            {
                Group group = new Group {
                    GroupID = groupID
                };
                _DatabaseContext.Groups.Attach(group);
                _DatabaseContext.Groups.DeleteObject(group);
                groupsToBeDeleted.Add(group);
                OnGroupDeleting(group);
            }

            int numberOfAffectedRows = _DatabaseContext.SaveChanges();

            if (numberOfAffectedRows != groupIDsToDelete.Count)
            {
                throw new DataNotUpdatedException("One or more group records have not been deleted.");
            }
            foreach (Group groupToBeDeleted in groupsToBeDeleted)
            {
                OnGroupDeleted(groupToBeDeleted);
            }
        }
Exemplo n.º 10
0
        public void DeleteTokenTypes(List <int> tokenTypeIDsToDelete)
        {
            //Validate Input
            foreach (int tokenTypeID in tokenTypeIDsToDelete)
            {
                if (tokenTypeID.IsInvalidKey())
                {
                    BusinessLayerHelper.ThrowErrorForInvalidDataKey("TokenTypeID");
                }
            }

            List <TokenType> tokenTypesToBeDeleted = new List <TokenType>();

            foreach (int tokenTypeID in tokenTypeIDsToDelete)
            {
                TokenType tokenType = new TokenType {
                    TokenTypeID = tokenTypeID
                };
                _DatabaseContext.TokenTypes.Attach(tokenType);
                _DatabaseContext.TokenTypes.DeleteObject(tokenType);
                tokenTypesToBeDeleted.Add(tokenType);
                OnTokenTypeDeleting(tokenType);
            }

            int numberOfAffectedRows = _DatabaseContext.SaveChanges();

            if (numberOfAffectedRows != tokenTypeIDsToDelete.Count)
            {
                throw new DataNotUpdatedException("One or more tokenType records have not been deleted.");
            }
            foreach (TokenType tokenTypeToBeDeleted in tokenTypesToBeDeleted)
            {
                OnTokenTypeDeleted(tokenTypeToBeDeleted);
            }
        }
Exemplo n.º 11
0
        public void DeleteUser(User userToBeDeleted)
        {
            //Validate Input
            if (userToBeDeleted == null)
            {
                throw (new ArgumentNullException("userToBeDeleted"));
            }

            // Validate Primary key value
            if (userToBeDeleted.UserID.IsInvalidKey())
            {
                BusinessLayerHelper.ThrowErrorForInvalidDataKey("UserID");
            }

            OnUserSaving(userToBeDeleted);
            OnUserDeleting(userToBeDeleted);

            if (userToBeDeleted.EntityState == EntityState.Detached)
            {
                _DatabaseContext.Users.Attach(userToBeDeleted);
            }
            _DatabaseContext.Users.DeleteObject(userToBeDeleted);
            int numberOfAffectedRows = _DatabaseContext.SaveChanges();

            if (numberOfAffectedRows == 0)
            {
                throw new DataNotUpdatedException("No User deleted!");
            }

            OnUserDeleted(userToBeDeleted);
            OnUserSaved(userToBeDeleted);
        }
        public void DeleteEmployees(List <int> employeeIdsToDelete)
        {
            //Validate Input
            foreach (int employeeId in employeeIdsToDelete)
            {
                if (employeeId.IsInvalidKey())
                {
                    BusinessLayerHelper.ThrowErrorForInvalidDataKey("EmployeeId");
                }
            }

            List <Employee> employeesToBeDeleted = new List <Employee>();

            foreach (int employeeId in employeeIdsToDelete)
            {
                Employee employee = new Employee {
                    EmployeeId = employeeId
                };
                _DatabaseContext.Employees.Attach(employee);
                _DatabaseContext.Employees.DeleteObject(employee);
                employeesToBeDeleted.Add(employee);
                OnEmployeeDeleting(employee);
            }

            int numberOfAffectedRows = _DatabaseContext.SaveChanges();

            if (numberOfAffectedRows != employeeIdsToDelete.Count)
            {
                throw new DataNotUpdatedException("One or more employee records have not been deleted.");
            }
            foreach (Employee employeeToBeDeleted in employeesToBeDeleted)
            {
                OnEmployeeDeleted(employeeToBeDeleted);
            }
        }
        public void DeleteEmployee(Employee employeeToBeDeleted)
        {
            //Validate Input
            if (employeeToBeDeleted == null)
            {
                throw (new ArgumentNullException("employeeToBeDeleted"));
            }

            // Validate Primary key value
            if (employeeToBeDeleted.EmployeeId.IsInvalidKey())
            {
                BusinessLayerHelper.ThrowErrorForInvalidDataKey("EmployeeId");
            }

            OnEmployeeSaving(employeeToBeDeleted);
            OnEmployeeDeleting(employeeToBeDeleted);

            if (employeeToBeDeleted.EntityState == EntityState.Detached)
            {
                _DatabaseContext.Employees.Attach(employeeToBeDeleted);
            }
            _DatabaseContext.Employees.DeleteObject(employeeToBeDeleted);
            int numberOfAffectedRows = _DatabaseContext.SaveChanges();

            if (numberOfAffectedRows == 0)
            {
                throw new DataNotUpdatedException("No Employee deleted!");
            }

            OnEmployeeDeleted(employeeToBeDeleted);
            OnEmployeeSaved(employeeToBeDeleted);
        }
Exemplo n.º 14
0
        public void DeleteTreeDetails(List <int> treeDetailsIDsToDelete)
        {
            //Validate Input
            foreach (int treeDetailsID in treeDetailsIDsToDelete)
            {
                if (treeDetailsID.IsInvalidKey())
                {
                    BusinessLayerHelper.ThrowErrorForInvalidDataKey("TreeDetailsID");
                }
            }

            List <TreeDetail> treeDetailsToBeDeleted = new List <TreeDetail>();

            foreach (int treeDetailsID in treeDetailsIDsToDelete)
            {
                TreeDetail treeDetail = new TreeDetail {
                    TreeDetailsID = treeDetailsID
                };
                _DatabaseContext.TreeDetails.Attach(treeDetail);
                _DatabaseContext.TreeDetails.DeleteObject(treeDetail);
                treeDetailsToBeDeleted.Add(treeDetail);
                OnTreeDetailDeleting(treeDetail);
            }

            int numberOfAffectedRows = _DatabaseContext.SaveChanges();

            if (numberOfAffectedRows != treeDetailsIDsToDelete.Count)
            {
                throw new DataNotUpdatedException("One or more treeDetail records have not been deleted.");
            }
            foreach (TreeDetail treeDetailToBeDeleted in treeDetailsToBeDeleted)
            {
                OnTreeDetailDeleted(treeDetailToBeDeleted);
            }
        }
Exemplo n.º 15
0
        public void DeleteRole_Users(List <int> roleUserIDsToDelete)
        {
            //Validate Input
            foreach (int roleUserID in roleUserIDsToDelete)
            {
                if (roleUserID.IsInvalidKey())
                {
                    BusinessLayerHelper.ThrowErrorForInvalidDataKey("RoleUserID");
                }
            }

            List <Role_Users> role_UserssToBeDeleted = new List <Role_Users>();

            foreach (int roleUserID in roleUserIDsToDelete)
            {
                Role_Users role_Users = new Role_Users {
                    RoleUserID = roleUserID
                };
                _DatabaseContext.Role_Users.Attach(role_Users);
                _DatabaseContext.Role_Users.DeleteObject(role_Users);
                role_UserssToBeDeleted.Add(role_Users);
                OnRole_UsersDeleting(role_Users);
            }

            int numberOfAffectedRows = _DatabaseContext.SaveChanges();

            if (numberOfAffectedRows != roleUserIDsToDelete.Count)
            {
                throw new DataNotUpdatedException("One or more role_Users records have not been deleted.");
            }
            foreach (Role_Users role_UsersToBeDeleted in role_UserssToBeDeleted)
            {
                OnRole_UsersDeleted(role_UsersToBeDeleted);
            }
        }
Exemplo n.º 16
0
        public void DeleteConditions(List <int> conditionIDsToDelete)
        {
            //Validate Input
            foreach (int conditionID in conditionIDsToDelete)
            {
                if (conditionID.IsInvalidKey())
                {
                    BusinessLayerHelper.ThrowErrorForInvalidDataKey("ConditionID");
                }
            }

            List <Condition> conditionsToBeDeleted = new List <Condition>();

            foreach (int conditionID in conditionIDsToDelete)
            {
                Condition condition = new Condition {
                    ConditionID = conditionID
                };
                _DatabaseContext.Conditions.Attach(condition);
                _DatabaseContext.Conditions.DeleteObject(condition);
                conditionsToBeDeleted.Add(condition);
                OnConditionDeleting(condition);
            }

            int numberOfAffectedRows = _DatabaseContext.SaveChanges();

            if (numberOfAffectedRows != conditionIDsToDelete.Count)
            {
                throw new DataNotUpdatedException("One or more condition records have not been deleted.");
            }
            foreach (Condition conditionToBeDeleted in conditionsToBeDeleted)
            {
                OnConditionDeleted(conditionToBeDeleted);
            }
        }
Exemplo n.º 17
0
        public void DeleteRep(Rep repToBeDeleted)
        {
            //Validate Input
            if (repToBeDeleted == null)
            {
                throw (new ArgumentNullException("repToBeDeleted"));
            }

            // Validate Primary key value
            if (repToBeDeleted.RepID.IsInvalidKey())
            {
                BusinessLayerHelper.ThrowErrorForInvalidDataKey("RepID");
            }

            OnRepSaving(repToBeDeleted);
            OnRepDeleting(repToBeDeleted);

            if (repToBeDeleted.EntityState == EntityState.Detached)
            {
                _DatabaseContext.Reps.Attach(repToBeDeleted);
            }
            _DatabaseContext.Reps.DeleteObject(repToBeDeleted);
            int numberOfAffectedRows = _DatabaseContext.SaveChanges();

            if (numberOfAffectedRows == 0)
            {
                throw new DataNotUpdatedException("No Rep deleted!");
            }

            OnRepDeleted(repToBeDeleted);
            OnRepSaved(repToBeDeleted);
        }
Exemplo n.º 18
0
        public void DeleteCity(City cityToBeDeleted)
        {
            //Validate Input
            if (cityToBeDeleted == null)
            {
                throw (new ArgumentNullException("cityToBeDeleted"));
            }

            // Validate Primary key value
            if (cityToBeDeleted.CityID.IsInvalidKey())
            {
                BusinessLayerHelper.ThrowErrorForInvalidDataKey("CityID");
            }

            OnCitySaving(cityToBeDeleted);
            OnCityDeleting(cityToBeDeleted);

            if (cityToBeDeleted.EntityState == EntityState.Detached)
            {
                _DatabaseContext.Cities.Attach(cityToBeDeleted);
            }
            _DatabaseContext.Cities.DeleteObject(cityToBeDeleted);
            int numberOfAffectedRows = _DatabaseContext.SaveChanges();

            if (numberOfAffectedRows == 0)
            {
                throw new DataNotUpdatedException("No City deleted!");
            }

            OnCityDeleted(cityToBeDeleted);
            OnCitySaved(cityToBeDeleted);
        }
Exemplo n.º 19
0
        public void DeleteOrganism(Organism organismToBeDeleted)
        {
            //Validate Input
            if (organismToBeDeleted == null)
            {
                throw (new ArgumentNullException("organismToBeDeleted"));
            }

            // Validate Primary key value
            if (organismToBeDeleted.OrganismID.IsInvalidKey())
            {
                BusinessLayerHelper.ThrowErrorForInvalidDataKey("OrganismID");
            }

            OnOrganismSaving(organismToBeDeleted);
            OnOrganismDeleting(organismToBeDeleted);

            if (organismToBeDeleted.EntityState == EntityState.Detached)
            {
                _DatabaseContext.Organisms.Attach(organismToBeDeleted);
            }
            _DatabaseContext.Organisms.DeleteObject(organismToBeDeleted);
            int numberOfAffectedRows = _DatabaseContext.SaveChanges();

            if (numberOfAffectedRows == 0)
            {
                throw new DataNotUpdatedException("No Organism deleted!");
            }

            OnOrganismDeleted(organismToBeDeleted);
            OnOrganismSaved(organismToBeDeleted);
        }
Exemplo n.º 20
0
        public void DeleteCities(List <int> cityIDsToDelete)
        {
            //Validate Input
            foreach (int cityID in cityIDsToDelete)
            {
                if (cityID.IsInvalidKey())
                {
                    BusinessLayerHelper.ThrowErrorForInvalidDataKey("CityID");
                }
            }

            List <City> citysToBeDeleted = new List <City>();

            foreach (int cityID in cityIDsToDelete)
            {
                City city = new City {
                    CityID = cityID
                };
                _DatabaseContext.Cities.Attach(city);
                _DatabaseContext.Cities.DeleteObject(city);
                citysToBeDeleted.Add(city);
                OnCityDeleting(city);
            }

            int numberOfAffectedRows = _DatabaseContext.SaveChanges();

            if (numberOfAffectedRows != cityIDsToDelete.Count)
            {
                throw new DataNotUpdatedException("One or more city records have not been deleted.");
            }
            foreach (City cityToBeDeleted in citysToBeDeleted)
            {
                OnCityDeleted(cityToBeDeleted);
            }
        }
Exemplo n.º 21
0
        public void DeleteProject(Project projectToBeDeleted)
        {
            //Validate Input
            if (projectToBeDeleted == null)
            {
                throw (new ArgumentNullException("projectToBeDeleted"));
            }

            // Validate Primary key value
            if (projectToBeDeleted.ProjectID.IsInvalidKey())
            {
                BusinessLayerHelper.ThrowErrorForInvalidDataKey("ProjectID");
            }

            OnProjectSaving(projectToBeDeleted);
            OnProjectDeleting(projectToBeDeleted);

            if (projectToBeDeleted.EntityState == EntityState.Detached)
            {
                _DatabaseContext.Projects.Attach(projectToBeDeleted);
            }
            _DatabaseContext.Projects.DeleteObject(projectToBeDeleted);
            int numberOfAffectedRows = _DatabaseContext.SaveChanges();

            if (numberOfAffectedRows == 0)
            {
                throw new DataNotUpdatedException("No Project deleted!");
            }

            OnProjectDeleted(projectToBeDeleted);
            OnProjectSaved(projectToBeDeleted);
        }
Exemplo n.º 22
0
        public Project GetProjectByProjectId2(int projectID)
        {
            //Validate Input
            if (projectID.IsInvalidKey())
            {
                BusinessLayerHelper.ThrowErrorForInvalidDataKey("projectID");
            }
            Project project = (_DatabaseContext.Projects.FirstOrDefault(instance => instance.ProjectID == projectID));

            if (project.ProjectInfoes.Count == 0)
            {
                ProjectInfo ProjectInfo = new ProjectInfo();
                ProjectInfo.ProjectID = project.ProjectID;

                ProjectInfo.ProjectReference.EntityKey = project.EntityKey;
                ProjectInfo.EditedDate = DateTime.Now;
                project.ProjectInfoes.Add(ProjectInfo);

                _DatabaseContext.SaveChanges();
            }

            var projectInfoes            = project.ProjectInfoes;
            var projectInfoTreeLocations = project.ProjectInfoTreeLocations;

            return(project);
        }
Exemplo n.º 23
0
        public void DeleteNotifications(List <int> notificationIDsToDelete)
        {
            //Validate Input
            foreach (int notificationID in notificationIDsToDelete)
            {
                if (notificationID.IsInvalidKey())
                {
                    BusinessLayerHelper.ThrowErrorForInvalidDataKey("NotificationID");
                }
            }

            List <Notification> notificationsToBeDeleted = new List <Notification>();

            foreach (int notificationID in notificationIDsToDelete)
            {
                Notification notification = new Notification {
                    NotificationID = notificationID
                };
                _DatabaseContext.Notifications.Attach(notification);
                _DatabaseContext.Notifications.DeleteObject(notification);
                notificationsToBeDeleted.Add(notification);
                OnNotificationDeleting(notification);
            }

            int numberOfAffectedRows = _DatabaseContext.SaveChanges();

            if (numberOfAffectedRows != notificationIDsToDelete.Count)
            {
                throw new DataNotUpdatedException("One or more notification records have not been deleted.");
            }
            foreach (Notification notificationToBeDeleted in notificationsToBeDeleted)
            {
                OnNotificationDeleted(notificationToBeDeleted);
            }
        }
Exemplo n.º 24
0
        public void DeletePerimeters(List <int> perimeterIDsToDelete)
        {
            //Validate Input
            foreach (int perimeterID in perimeterIDsToDelete)
            {
                if (perimeterID.IsInvalidKey())
                {
                    BusinessLayerHelper.ThrowErrorForInvalidDataKey("PerimeterID");
                }
            }

            List <Perimeter> perimetersToBeDeleted = new List <Perimeter>();

            foreach (int perimeterID in perimeterIDsToDelete)
            {
                Perimeter perimeter = new Perimeter {
                    PerimeterID = perimeterID
                };
                _DatabaseContext.Perimeters.Attach(perimeter);
                _DatabaseContext.Perimeters.DeleteObject(perimeter);
                perimetersToBeDeleted.Add(perimeter);
                OnPerimeterDeleting(perimeter);
            }

            int numberOfAffectedRows = _DatabaseContext.SaveChanges();

            if (numberOfAffectedRows != perimeterIDsToDelete.Count)
            {
                throw new DataNotUpdatedException("One or more perimeter records have not been deleted.");
            }
            foreach (Perimeter perimeterToBeDeleted in perimetersToBeDeleted)
            {
                OnPerimeterDeleted(perimeterToBeDeleted);
            }
        }
        public void DeleteTermsAndCondition(TermsAndCondition termsAndConditionToBeDeleted)
        {
            //Validate Input
            if (termsAndConditionToBeDeleted == null)
            {
                throw (new ArgumentNullException("termsAndConditionToBeDeleted"));
            }

            // Validate Primary key value
            if (termsAndConditionToBeDeleted.TermsAndConditionsID.IsInvalidKey())
            {
                BusinessLayerHelper.ThrowErrorForInvalidDataKey("TermsAndConditionsID");
            }

            OnTermsAndConditionSaving(termsAndConditionToBeDeleted);
            OnTermsAndConditionDeleting(termsAndConditionToBeDeleted);

            if (termsAndConditionToBeDeleted.EntityState == EntityState.Detached)
            {
                _DatabaseContext.TermsAndConditions.Attach(termsAndConditionToBeDeleted);
            }
            _DatabaseContext.TermsAndConditions.DeleteObject(termsAndConditionToBeDeleted);
            int numberOfAffectedRows = _DatabaseContext.SaveChanges();

            if (numberOfAffectedRows == 0)
            {
                throw new DataNotUpdatedException("No TermsAndCondition deleted!");
            }

            OnTermsAndConditionDeleted(termsAndConditionToBeDeleted);
            OnTermsAndConditionSaved(termsAndConditionToBeDeleted);
        }
        public void DeleteApplication_Groups(Application_Groups application_GroupsToBeDeleted)
        {
            //Validate Input
            if (application_GroupsToBeDeleted == null)
            {
                throw (new ArgumentNullException("application_GroupsToBeDeleted"));
            }

            // Validate Primary key value
            if (application_GroupsToBeDeleted.ApplicationGroupID.IsInvalidKey())
            {
                BusinessLayerHelper.ThrowErrorForInvalidDataKey("ApplicationGroupID");
            }

            OnApplication_GroupsSaving(application_GroupsToBeDeleted);
            OnApplication_GroupsDeleting(application_GroupsToBeDeleted);

            if (application_GroupsToBeDeleted.EntityState == EntityState.Detached)
            {
                _DatabaseContext.Application_Groups.Attach(application_GroupsToBeDeleted);
            }
            _DatabaseContext.Application_Groups.DeleteObject(application_GroupsToBeDeleted);
            int numberOfAffectedRows = _DatabaseContext.SaveChanges();

            if (numberOfAffectedRows == 0)
            {
                throw new DataNotUpdatedException("No Application_Groups deleted!");
            }

            OnApplication_GroupsDeleted(application_GroupsToBeDeleted);
            OnApplication_GroupsSaved(application_GroupsToBeDeleted);
        }
Exemplo n.º 27
0
        public void UpdateScientificName(ScientificName updatedScientificName)
        {
            // Validate Parameters
            if (updatedScientificName == null)
            {
                throw (new ArgumentNullException("updatedScientificName"));
            }

            // Validate Primary key value
            if (updatedScientificName.ScientificNameID.IsInvalidKey())
            {
                BusinessLayerHelper.ThrowErrorForInvalidDataKey("ScientificNameID");
            }

            // Apply business rules
            OnScientificNameSaving(updatedScientificName);
            OnScientificNameUpdating(updatedScientificName);

            //attaching and making ready for parsistance
            if (updatedScientificName.EntityState == EntityState.Detached)
            {
                _DatabaseContext.ScientificNames.Attach(updatedScientificName);
            }
            _DatabaseContext.ObjectStateManager.ChangeObjectState(updatedScientificName, System.Data.EntityState.Modified);            //this line makes the code un-testable!
            int numberOfAffectedRows = _DatabaseContext.SaveChanges();

            if (numberOfAffectedRows == 0)
            {
                throw new DataNotUpdatedException("No scientificName updated!");
            }

            //Apply business workflow
            OnScientificNameUpdated(updatedScientificName);
            OnScientificNameSaved(updatedScientificName);
        }
        public void DeleteApplication_Groups(List <int> applicationGroupIDsToDelete)
        {
            //Validate Input
            foreach (int applicationGroupID in applicationGroupIDsToDelete)
            {
                if (applicationGroupID.IsInvalidKey())
                {
                    BusinessLayerHelper.ThrowErrorForInvalidDataKey("ApplicationGroupID");
                }
            }

            List <Application_Groups> application_GroupssToBeDeleted = new List <Application_Groups>();

            foreach (int applicationGroupID in applicationGroupIDsToDelete)
            {
                Application_Groups application_Groups = new Application_Groups {
                    ApplicationGroupID = applicationGroupID
                };
                _DatabaseContext.Application_Groups.Attach(application_Groups);
                _DatabaseContext.Application_Groups.DeleteObject(application_Groups);
                application_GroupssToBeDeleted.Add(application_Groups);
                OnApplication_GroupsDeleting(application_Groups);
            }

            int numberOfAffectedRows = _DatabaseContext.SaveChanges();

            if (numberOfAffectedRows != applicationGroupIDsToDelete.Count)
            {
                throw new DataNotUpdatedException("One or more application_Groups records have not been deleted.");
            }
            foreach (Application_Groups application_GroupsToBeDeleted in application_GroupssToBeDeleted)
            {
                OnApplication_GroupsDeleted(application_GroupsToBeDeleted);
            }
        }
Exemplo n.º 29
0
        public void DeleteScientificNames(List <int> scientificNameIDsToDelete)
        {
            //Validate Input
            foreach (int scientificNameID in scientificNameIDsToDelete)
            {
                if (scientificNameID.IsInvalidKey())
                {
                    BusinessLayerHelper.ThrowErrorForInvalidDataKey("ScientificNameID");
                }
            }

            List <ScientificName> scientificNamesToBeDeleted = new List <ScientificName>();

            foreach (int scientificNameID in scientificNameIDsToDelete)
            {
                ScientificName scientificName = new ScientificName {
                    ScientificNameID = scientificNameID
                };
                _DatabaseContext.ScientificNames.Attach(scientificName);
                _DatabaseContext.ScientificNames.DeleteObject(scientificName);
                scientificNamesToBeDeleted.Add(scientificName);
                OnScientificNameDeleting(scientificName);
            }

            int numberOfAffectedRows = _DatabaseContext.SaveChanges();

            if (numberOfAffectedRows != scientificNameIDsToDelete.Count)
            {
                throw new DataNotUpdatedException("One or more scientificName records have not been deleted.");
            }
            foreach (ScientificName scientificNameToBeDeleted in scientificNamesToBeDeleted)
            {
                OnScientificNameDeleted(scientificNameToBeDeleted);
            }
        }
Exemplo n.º 30
0
        public void DeleteGroup_Users(Group_Users group_UsersToBeDeleted)
        {
            //Validate Input
            if (group_UsersToBeDeleted == null)
            {
                throw (new ArgumentNullException("group_UsersToBeDeleted"));
            }

            // Validate Primary key value
            if (group_UsersToBeDeleted.GroupUserID.IsInvalidKey())
            {
                BusinessLayerHelper.ThrowErrorForInvalidDataKey("GroupUserID");
            }

            OnGroup_UsersSaving(group_UsersToBeDeleted);
            OnGroup_UsersDeleting(group_UsersToBeDeleted);

            if (group_UsersToBeDeleted.EntityState == EntityState.Detached)
            {
                _DatabaseContext.Group_Users.Attach(group_UsersToBeDeleted);
            }
            _DatabaseContext.Group_Users.DeleteObject(group_UsersToBeDeleted);
            int numberOfAffectedRows = _DatabaseContext.SaveChanges();

            if (numberOfAffectedRows == 0)
            {
                throw new DataNotUpdatedException("No Group_Users deleted!");
            }

            OnGroup_UsersDeleted(group_UsersToBeDeleted);
            OnGroup_UsersSaved(group_UsersToBeDeleted);
        }