/// <summary>
        /// Deletes a/an OrganizationPrivilege.
        /// </summary>
        /// <param name="entity"></param>
        /// <returns>Returns an int for the result.</returns>
        public int DeleteOrganizationPrivilegeById(int id)
        {
            try
            {
			    var entity = GetOrganizationPrivilegeById(id);
                return repo.Delete<OrganizationPrivilege>(entity);
            }
            catch (Exception ex)
            {
                repo.LogError(ex);
                throw ex;
            }
        }
Beispiel #2
0
 /// <summary>
 /// Deletes a/an GroupPrivilege.
 /// </summary>
 /// <param name="entity"></param>
 /// <returns>Returns an int for the result.</returns>
 public int DeleteGroupPrivilegeById(int id)
 {
     try
     {
         var entity = GetGroupPrivilegeById(id);
         return(repo.Delete <GroupPrivilege>(entity));
     }
     catch (Exception ex)
     {
         repo.LogError(ex);
         throw ex;
     }
 }
Beispiel #3
0
 /// <summary>
 /// Deletes a/an User.
 /// </summary>
 /// <param name="entity"></param>
 /// <returns>Returns an int for the result.</returns>
 public int DeleteUserById(System.Guid id)
 {
     try
     {
         var entity = GetUserById(id);
         return(repo.Delete <User>(entity));
     }
     catch (Exception ex)
     {
         repo.LogError(ex);
         throw ex;
     }
 }
 /// <summary>
 /// Deletes a/an UserGroup.
 /// </summary>
 /// <param name="entity"></param>
 /// <returns>Returns an int for the result.</returns>
 public int DeleteUserGroupById(int id)
 {
     try
     {
         var entity = GetUserGroupById(id);
         return(repo.Delete <UserGroup>(entity));
     }
     catch (Exception ex)
     {
         repo.LogError(ex);
         throw ex;
     }
 }
 /// <summary>
 /// Deletes a/an LogEvent.
 /// </summary>
 /// <param name="entity"></param>
 /// <returns>Returns an int for the result.</returns>
 public int DeleteLogEventById(int id)
 {
     try
     {
         var entity = GetLogEventById(id);
         return(repo.Delete <LogEvent>(entity));
     }
     catch (Exception ex)
     {
         repo.LogError(ex);
         throw ex;
     }
 }
 /// <summary>
 /// Deletes a/an Application.
 /// </summary>
 /// <param name="entity"></param>
 /// <returns>Returns an int for the result.</returns>
 public int DeleteApplicationById(int id)
 {
     try
     {
         var entity = GetApplicationById(id);
         return(repo.Delete <Application>(entity));
     }
     catch (Exception ex)
     {
         repo.LogError(ex);
         throw ex;
     }
 }
Beispiel #7
0
        public int Delete <T>(T t) where T : class
        {
            try
            {
                // Log the Create event type
                LogEvent log = new LogEvent();
                //log.LogEventType = LogEventType.Delete;
                log.LogEventType = "Delete";

                // Log the user name, Id, and current date
                log.ChangedByUserId   = this.GetCurrentUserId();
                log.ChangedByUserName = this.GetCurrentUserName();
                log.Date = DateTime.Now;


                // Log the enitity type and primary key that will be deleted
                Type entityType = typeof(T);
                log.EntityType = entityType.Name;

                // Log the primary key/Id for the entity based on the config data
                // Note: This assumes the class names for the db model match the table names
                var configProp     = loggingConfig_PrimaryKeys.GetType().GetProperty(entityType.Name);
                var primaryKeyName = configProp.GetValue(loggingConfig_PrimaryKeys, null).ToString();
                var entityProp     = t.GetType().GetProperty(primaryKeyName);
                log.EntityId = entityProp.GetValue(t, null).ToString();

                // Save the log to the database
                repo.Create <LogEvent>(log);

                return(repo.Delete <T>(t));
            }
            catch (Exception ex)
            {
                LogError(ex);
                throw ex;
            }
        }