public IdentityPolicy GetById(int Id) { var info = new IdentityPolicy(); var sqlCmd = @"Policy_GetById"; var parameters = new Dictionary <string, object> { { "@Id", Id } }; try { using (var conn = new SqlConnection(_connectionString)) { using (var reader = MsSqlHelper.ExecuteReader(conn, CommandType.StoredProcedure, sqlCmd, parameters)) { while (reader.Read()) { info = ExtractPolicyData(reader); } } } } catch (Exception ex) { var strError = "Failed to execute Policy_GetById. Error: " + ex.Message; throw new CustomSQLException(strError); } return(info); }
public bool Update(IdentityPolicy identity) { //Common syntax var sqlCmd = @"Policy_Update"; //For parameters var parameters = new Dictionary <string, object> { { "@Id", identity.Id }, { "@Name", identity.Name }, { "@Code", identity.Code }, { "@LastUpdatedBy", identity.LastUpdatedBy }, { "@Status", identity.Status } }; try { using (var conn = new SqlConnection(_connectionString)) { MsSqlHelper.ExecuteNonQuery(conn, CommandType.StoredProcedure, sqlCmd, parameters); } } catch (Exception ex) { var strError = "Failed to execute Policy_Update. Error: " + ex.Message; throw new CustomSQLException(strError); } return(true); }
public int Insert(IdentityPolicy identity) { //Common syntax var sqlCmd = @"Policy_Insert"; var newId = 0; //For parameters var parameters = new Dictionary <string, object> { { "@Name", identity.Name }, { "@Code", identity.Code }, { "@CreatedBy", identity.CreatedBy }, { "@Status", identity.Status } }; try { using (var conn = new SqlConnection(_connectionString)) { var returnObj = MsSqlHelper.ExecuteScalar(conn, CommandType.StoredProcedure, sqlCmd, parameters); newId = Convert.ToInt32(returnObj); } } catch (Exception ex) { var strError = "Failed to execute Policy_Insert. Error: " + ex.Message; throw new CustomSQLException(strError); } return(newId); }
/// <summary> /// Page load event. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void Page_Load(object sender, System.EventArgs e) { // connection web = Session["Connection"] as iFolderAdmin; // localization rm = Application["RM"] as ResourceManager; //string userID = Session[ "UserID" ] as String; if (!IsPostBack) { // Initialize the localized fields. DisableButton.Text = GetString("DISABLE"); EnableButton.Text = GetString("ENABLE"); ProvisionButton.Text = GetString("PROVISION"); SaveButton.Text = GetString("SAVE"); // Initialize state variables. CurrentUserOffset = 0; TotalUsers = 0; AllUsersCheckBox.Checked = false; CheckedUsers = new Hashtable(); ServerProvisioningNames = new Hashtable(); IdentityPolicy policy = web.GetIdentityPolicy(); if (policy.CanCreate) { CreateButton.Text = GetString("CREATE"); CreateButton.Visible = true; } if (policy.CanDelete) { DeleteButton.Text = GetString("DELETE"); DeleteButton.Visible = true; } // Get the owner of the system. iFolder domain = web.GetiFolder(web.GetSystem().ID); SuperAdminID = domain.OwnerID; } // In ru/pl/hu as the PROVISION string is too long , increase the width for this language. string code = Thread.CurrentThread.CurrentUICulture.Name; if (code.StartsWith("ru") || code.StartsWith("hu")) { ProvisionButton.Width = 250; } else if (code.StartsWith("pl")) { ProvisionButton.Width = 180; } else if (code.StartsWith("pt") || code.StartsWith("de")) { DisableButton.Width = 120; } }
private IdentityPolicy ExtractPolicyData(IDataReader reader) { var record = new IdentityPolicy(); //Seperate properties record.Id = Utils.ConvertToInt32(reader["Id"]); record.Name = reader["Name"].ToString(); record.Code = reader["Code"].ToString(); record.CreatedBy = reader["CreatedBy"].ToString(); record.CreatedDate = reader["CreatedDate"] == DBNull.Value ? null : (DateTime?)reader["CreatedDate"]; record.LastUpdated = reader["LastUpdated"] == DBNull.Value ? null : (DateTime?)reader["LastUpdated"]; record.LastUpdatedBy = reader["LastUpdatedBy"].ToString(); record.Status = Utils.ConvertToInt32(reader["Status"]); return(record); }
public List <IdentityPolicy> GetAll(IdentityPolicy filter, int currentPage, int pageSize) { //Common syntax var sqlCmd = @"Policy_GetAll"; List <IdentityPolicy> listData = null; //For paging int offset = (currentPage - 1) * pageSize; //For parameters var parameters = new Dictionary <string, object> { { "@Name", filter.Name }, { "@Code", filter.Code }, { "@Status", filter.Status }, { "@TuNgay", filter.FromDate }, { "@DenNgay", filter.ToDate }, { "@Offset", offset }, { "@PageSize", pageSize }, }; try { using (var conn = new SqlConnection(_connectionString)) { using (var reader = MsSqlHelper.ExecuteReader(conn, CommandType.StoredProcedure, sqlCmd, parameters)) { listData = ParsingListPolicyFromReader(reader); } } } catch (Exception ex) { var strError = "Failed to execute Policy_GetAll. Error: " + ex.Message; throw new CustomSQLException(strError); } return(listData); }
public bool Update(IdentityPolicy identity) { return(myRepository.Update(identity)); }
public int Insert(IdentityPolicy identity) { return(myRepository.Insert(identity)); }
public List <IdentityPolicy> GetAll(IdentityPolicy filter, int currentPage, int pageSize) { return(myRepository.GetAll(filter, currentPage, pageSize)); }