/// <summary>Insert or Update UserRole.</summary> /// <param name="privilegeList">The List of AddRoleUser Object.</param> /// <param name="role">The RoleUserlist Object.</param> /// <returns>Boolean Object.</returns> public bool UserRoleUpsert(List <AddRoleUser> privilegeList, RoleUserlist role) { Logging.LogDebugMessage("Method: UserRoleUpsert, MethodType: Post, Layer: SecurityDAL, Parameters: privilegeList = " + JsonConvert.SerializeObject(privilegeList) + ",role = " + JsonConvert.SerializeObject(role)); bool checkUserRole = false; DataSet dataSet = new DataSet(); var res = new List <AddRoleUser>(); DataTable dataTable = new DataTable(); dataTable = EntityCollectionHelper.ConvertTo <AddRoleUser>(privilegeList); try { using (var command = new SqlCommand()) { command.Connection = new SqlConnection(this.connectionString); command.CommandText = "USP_UserRoleUpsert"; command.CommandType = CommandType.StoredProcedure; command.Parameters.Add(new SqlParameter() { ParameterName = "@RoleID", Value = role.RoleId }); //command.Parameters.Add(new SqlParameter() { ParameterName = "@PrivilegeTable", Value = dataTable }); SqlParameter structuredParam = new SqlParameter("@UserTable", SqlDbType.Structured); structuredParam.Value = dataTable; command.Parameters.Add(structuredParam); command.Parameters.Add(new SqlParameter() { ParameterName = "@UpdatedByUserID", Value = role.UpdateUserId }); using (SqlDataAdapter adapter = new SqlDataAdapter(command)) { adapter.Fill(dataSet); if (dataSet != null) { checkUserRole = true; } else { checkUserRole = false; } } } } catch (SqlException sqlEx) { Logging.LogErrorMessage("Method: UserRoleUpsert, Layer: SecurityDAL, Stack Trace: " + sqlEx.ToString()); throw; } catch (Exception ex) { Logging.LogErrorMessage("Method: UserRoleUpsert, Layer: SecurityDAL, Stack Trace: " + ex.ToString()); throw; } return(checkUserRole); }
public bool UserRoleUpsert(AddUserRoleObj UserRoleList) { Logging.LogDebugMessage("Method: UserRoleUpsert, MethodType: Post, Layer: SecurityController, Parameters: userRoleList = " + JsonConvert.SerializeObject(UserRoleList)); using (SecurityBL userRoleUpsert = new SecurityBL()) { RoleUserlist roleobj = new RoleUserlist(); roleobj = UserRoleList.roleuserlist; List <AddRoleUser> userRoleList = new List <AddRoleUser>(); userRoleList = UserRoleList.Addroleuser; return(userRoleUpsert.UserRoleUpsert(userRoleList, roleobj)); } }
/// <summary>Insert or Update UserRole.</summary> /// <param name="privilegeList">The List of AddRoleUser Object.</param> /// <param name="rolePrivilege">The RoleUserlist Object.</param> /// <returns>Boolean Object.</returns> public bool UserRoleUpsert(List <AddRoleUser> privilegeList, RoleUserlist rolePrivilege) { Logging.LogDebugMessage("Method: UserRoleUpsert, MethodType: Post, Layer: SecurityBL, Parameters: privilegelist = " + JsonConvert.SerializeObject(privilegeList) + ",rolePrivilege = " + JsonConvert.SerializeObject(rolePrivilege)); using (SecurityDAL useRoleUpsert = new SecurityDAL()) { try { return(useRoleUpsert.UserRoleUpsert(privilegeList, rolePrivilege)); } catch (SqlException sqlEx) { Logging.LogErrorMessage("Method: UserRoleUpsert, Layer: SecurityBL, Stack Trace: " + sqlEx.ToString()); throw; } catch (Exception ex) { Logging.LogErrorMessage("Method: UserRoleUpsert, Layer: SecurityBL, Stack Trace: " + ex.ToString()); throw; } } }