Ejemplo n.º 1
0
        public void DeleteNotification_User(List <int> notificationUserIDsToDelete)
        {
            //Validate Input
            foreach (int notificationUserID in notificationUserIDsToDelete)
            {
                if (notificationUserID.IsInvalidKey())
                {
                    BusinessLayerHelper.ThrowErrorForInvalidDataKey("NotificationUserID");
                }
            }

            List <Notification_User> notification_UsersToBeDeleted = new List <Notification_User>();

            foreach (int notificationUserID in notificationUserIDsToDelete)
            {
                Notification_User notification_User = new Notification_User {
                    NotificationUserID = notificationUserID
                };
                _DatabaseContext.Notification_User.Attach(notification_User);
                _DatabaseContext.Notification_User.DeleteObject(notification_User);
                notification_UsersToBeDeleted.Add(notification_User);
                OnNotification_UserDeleting(notification_User);
            }

            int numberOfAffectedRows = _DatabaseContext.SaveChanges();

            if (numberOfAffectedRows != notificationUserIDsToDelete.Count)
            {
                throw new DataNotUpdatedException("One or more notification_User records have not been deleted.");
            }
            foreach (Notification_User notification_UserToBeDeleted in notification_UsersToBeDeleted)
            {
                OnNotification_UserDeleted(notification_UserToBeDeleted);
            }
        }
Ejemplo n.º 2
0
        public void DeleteNotification_User(Notification_User notification_UserToBeDeleted)
        {
            //Validate Input
            if (notification_UserToBeDeleted == null)
            {
                throw (new ArgumentNullException("notification_UserToBeDeleted"));
            }

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

            OnNotification_UserSaving(notification_UserToBeDeleted);
            OnNotification_UserDeleting(notification_UserToBeDeleted);

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

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

            OnNotification_UserDeleted(notification_UserToBeDeleted);
            OnNotification_UserSaved(notification_UserToBeDeleted);
        }
Ejemplo n.º 3
0
        public void UpdateNotification_User(Notification_User updatedNotification_User)
        {
            // Validate Parameters
            if (updatedNotification_User == null)
            {
                throw (new ArgumentNullException("updatedNotification_User"));
            }

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

            // Apply business rules
            OnNotification_UserSaving(updatedNotification_User);
            OnNotification_UserUpdating(updatedNotification_User);

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

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

            //Apply business workflow
            OnNotification_UserUpdated(updatedNotification_User);
            OnNotification_UserSaved(updatedNotification_User);
        }
Ejemplo n.º 4
0
        public virtual int CreateNewNotification_User(Notification_User newNotification_User)
        {
            // Validate Parameters
            if (newNotification_User == null)
            {
                throw (new ArgumentNullException("newNotification_User"));
            }

            // Apply business rules
            OnNotification_UserSaving(newNotification_User);
            OnNotification_UserCreating(newNotification_User);

            _DatabaseContext.Notification_User.AddObject(newNotification_User);
            int numberOfAffectedRows = _DatabaseContext.SaveChanges();

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

            // Apply business workflow
            OnNotification_UserCreated(newNotification_User);
            OnNotification_UserSaved(newNotification_User);

            return(newNotification_User.NotificationUserID);
        }
Ejemplo n.º 5
0
 /// <summary>
 /// Deprecated Method for adding a new object to the Notification_User EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToNotification_User(Notification_User notification_User)
 {
     base.AddObject("Notification_User", notification_User);
 }
Ejemplo n.º 6
0
 partial void OnNotification_UserDeleted(Notification_User notification_User);
Ejemplo n.º 7
0
 partial void OnNotification_UserSaved(Notification_User notification_User);
Ejemplo n.º 8
0
 partial void OnNotification_UserUpdated(Notification_User notification_User);
Ejemplo n.º 9
0
 partial void OnNotification_UserCreated(Notification_User notification_User);