コード例 #1
0
        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);
            }
        }
コード例 #2
0
        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);
        }
コード例 #3
0
        public void UpdateApplication_Groups(Application_Groups updatedApplication_Groups)
        {
            // Validate Parameters
            if (updatedApplication_Groups == null)
            {
                throw (new ArgumentNullException("updatedApplication_Groups"));
            }

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

            // Apply business rules
            OnApplication_GroupsSaving(updatedApplication_Groups);
            OnApplication_GroupsUpdating(updatedApplication_Groups);

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

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

            //Apply business workflow
            OnApplication_GroupsUpdated(updatedApplication_Groups);
            OnApplication_GroupsSaved(updatedApplication_Groups);
        }
コード例 #4
0
        public virtual int CreateNewApplication_Groups(Application_Groups newApplication_Groups)
        {
            // Validate Parameters
            if (newApplication_Groups == null)
            {
                throw (new ArgumentNullException("newApplication_Groups"));
            }

            // Apply business rules
            OnApplication_GroupsSaving(newApplication_Groups);
            OnApplication_GroupsCreating(newApplication_Groups);

            _DatabaseContext.Application_Groups.AddObject(newApplication_Groups);
            int numberOfAffectedRows = _DatabaseContext.SaveChanges();

            if (numberOfAffectedRows == 0)
            {
                throw new DataNotUpdatedException("No application_Groups created!");
            }

            // Apply business workflow
            OnApplication_GroupsCreated(newApplication_Groups);
            OnApplication_GroupsSaved(newApplication_Groups);

            return(newApplication_Groups.ApplicationGroupID);
        }
コード例 #5
0
 /// <summary>
 /// Deprecated Method for adding a new object to the Application_Groups EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToApplication_Groups(Application_Groups application_Groups)
 {
     base.AddObject("Application_Groups", application_Groups);
 }
コード例 #6
0
 partial void OnApplication_GroupsDeleted(Application_Groups application_Groups);
コード例 #7
0
 partial void OnApplication_GroupsSaved(Application_Groups application_Groups);
コード例 #8
0
 partial void OnApplication_GroupsUpdated(Application_Groups application_Groups);
コード例 #9
0
 partial void OnApplication_GroupsCreated(Application_Groups application_Groups);