Пример #1
0
 public bool Delete(WebUserRoleDTO note)
 {
     using (var connection = new SqlConnection(connectionString))
     {
         var delete_web_user = connection.CreateCommand();
         delete_web_user.CommandText = $"DELETE FROM dbo.WebUserRoles WHERE WebUserId = @WebUserId AND RoleId = @RoleId";
         delete_web_user.Parameters.AddWithValue("@WebUserId", note.WebUserId);
         delete_web_user.Parameters.AddWithValue("@RoleId", note.RoleId);
         connection.Open();
         var result = delete_web_user.ExecuteNonQuery();
         return(result > 0);
     }
 }
Пример #2
0
 public bool Create(WebUserRoleDTO note)
 {
     using (var connection = new SqlConnection(connectionString))
     {
         var add_web_user_role = connection.CreateCommand();
         add_web_user_role.CommandText = $"INSERT INTO dbo.WebUserRoles (WebUserId, RoleId) VALUES (@WebUserId, @RoleId)";
         add_web_user_role.Parameters.AddWithValue("@WebUserId", note.WebUserId);
         add_web_user_role.Parameters.AddWithValue("@RoleId", note.RoleId);
         connection.Open();
         var result = add_web_user_role.ExecuteNonQuery();
         return(result > 0);
     }
 }
Пример #3
0
        public bool Delete(WebUserRoleDTO note)
        {
            try
            {
                return(dal_web_user_role.Delete(note));
            }

            catch (Exception e)
            {
                Logger.Logger.WriteLog(e);
                throw e;
            }
        }
Пример #4
0
 public bool Update(WebUserRoleDTO note)
 {
     using (var connection = new SqlConnection(connectionString))
     {
         var update_web_user = connection.CreateCommand();
         update_web_user.CommandText = $"UPDATE dbo.WebUsers SET Id = @Id , WebUserId = @WebUserId, RoleId = @RoleId WHERE Id = @Id";
         update_web_user.Parameters.AddWithValue("@Id", note.Id);
         update_web_user.Parameters.AddWithValue("@WebUserId", note.WebUserId);
         update_web_user.Parameters.AddWithValue("@RoleId", note.RoleId);
         connection.Open();
         var result = update_web_user.ExecuteNonQuery();
         return(result > 0);
     }
 }
Пример #5
0
        public bool Update(WebUserRoleDTO note)
        {
            try
            {
                dal_web_user_role.Update(note);
                return(true);
            }

            catch (Exception e)
            {
                Logger.Logger.WriteLog(e);
                throw e;
            }
        }