public ActionResult UpdateRoleConfig(int id, Models.RoleSettingModel m) { // Xử lý cập nhật thông tin cho Role if (id > 0) { RoleService roleService = new RoleService(); Entities.Role e = roleService.GetById(id); if (e != null) { e.Post = m.Post; e.ResiveFromAgency = m.ResiveFromAgency; e.ResiveFromMember = m.ResiveFromMember; e.ResiveRegionNum = m.ResiveRegionNum; e.SendRegionNum = m.SendRegionNum; roleService.Save(e); } else { return(PartialView("_RolePartial", settingModel.RoleSetting)); } } settingModel.RoleSetting = GetRoleSetting(id); return(RedirectToAction("Index", "Setting")); }
public bool AddTaskToRole(Entities.Role role, Entities.Task task) { bool res = false; using (SqlConnection cnn = new SqlConnection(sqlCnnStr)) { string query = "INSERT INTO RoleTasks" + " (RoleId, TaskId)" + " VALUES " + " (@RoleId, @TaskId)"; using (SqlCommand cmd = new SqlCommand(query, cnn)) { cmd.CommandType = CommandType.Text; cmd.Parameters.Add(new SqlParameter("@TaskId", task.Id)); cmd.Parameters.Add(new SqlParameter("@RoleId", role.Id)); cnn.Open(); int affected = cmd.ExecuteNonQuery(); res = (affected > 0); } } return(res); }
public List <Entities.Role> GetRights() { using (MySql.Data.MySqlClient.MySqlCommand cmd = new MySql.Data.MySqlClient.MySqlCommand("SHOW FIELDS FROM rights;", con)) { List <Entities.Role> roles = new List <Entities.Role>(); try { con.Open(); MySqlDataReader reader = cmd.ExecuteReader(); while (reader.Read()) { Entities.Role role = new Entities.Role(); role.Description = reader.GetString(0); if (role.Description != "ID") { roles.Add(role); } } con.Close(); } catch (Exception ex) { throw new Exception(ex.Message); } return(roles); } }
public bool Insert(Entities.Role role) { bool res = false; using (SqlConnection cnn = new SqlConnection(sqlCnnStr)) { string query = "INSERT INTO Roles" + " (RoleName, RolePriority)" + " VALUES " + " (@RoleName, @RolePriority);" + " SELECT SCOPE_IDENTITY();"; using (SqlCommand cmd = new SqlCommand(query, cnn)) { cmd.CommandType = CommandType.Text; cmd.Parameters.Add(new SqlParameter("@RoleName", role.Name)); cmd.Parameters.Add(new SqlParameter("@RolePriority", role.Priority)); cnn.Open(); object id = cmd.ExecuteScalar(); if (id != null) { role.Id = Convert.ToInt32(id); res = true; } } } return(res); }
public List <Entities.Role> GetRoles() { List <Entities.Role> list = new List <Entities.Role>(); using (SqlConnection connection = new SqlConnection(Settings.Current.StorageSource)) { connection.Open(); using (SqlCommand command = new SqlCommand("Zesty_Role_List", connection)) { command.CommandType = System.Data.CommandType.StoredProcedure; using (SqlDataReader reader = command.ExecuteReader()) { while (reader.Read()) { Entities.Role role = new Entities.Role(); role.Id = reader.Get <Guid>("Id"); role.Name = reader.Get <string>("Name"); list.Add(role); } return(list); } } } }
public Entities.RoleCollection GetAll() { Entities.RoleCollection roles = new Entities.RoleCollection(); using (SqlConnection cnn = new SqlConnection(sqlCnnStr)) { string query = "SELECT * FROM Roles"; using (SqlCommand cmd = new SqlCommand(query, cnn)) { cmd.CommandType = CommandType.Text; cnn.Open(); using (SqlDataReader reader = cmd.ExecuteReader()) { if (reader != null && reader.HasRows) { while (reader.Read()) { Entities.Role role = new Entities.Role(); role.Id = Utils.GetSafeInt32(reader, "RoleId"); role.Name = Utils.GetSafeString(reader, "RoleName"); role.Priority = System.Convert.ToInt32(Utils.GetSafeString(reader, "RolePriority")); roles.Add(role); } } } } } return(roles); }
static public Entities.Role GetRole(DataRow role) { Entities.Role R = new Entities.Role(); R.Id = role.Field <int>("Id"); R.Role_Name = role.Field <string>("Role_Name"); return(R); }
protected void btnSave_Click(object sender, ImageClickEventArgs e) { Int32 records = 0; if (validateData()) { Entities.Role oRole = new Entities.Role(); oRole.Role_Id = Convert.ToInt32(txtCode.Text); oRole.Description = txtName.Text; oRole.State = Convert.ToInt32(cboState.SelectedValue); oRole.oListSystemModule = FillList(); if (RoleBLL.getInstance().exists(oRole.Role_Id)) { records = RoleBLL.getInstance().modify(oRole); } else { if (RoleBLL.getInstance().existsName(txtName.Text) == false) { records = RoleBLL.getInstance().insert(oRole);//To insert a role } else { lblMessage.Text = "Debe Utilizar otra descrpcion."; } } blockControls(); loadData(); if (records > 0) { lblMessage.Text = "Datos almacenados correctamente."; } } }
internal static void Edit(Entities.Role role) { using (FrmRoleEditor frm = new FrmRoleEditor(role)) { frm.ShowDialog(); } }
/// <summary> /// Delete the role by specified role id. /// </summary> /// <param name="role">Specifies an object of an Role entity class.</param> /// <returns>A boolean value True if records deleted else False.</returns> public bool DeleteRoleById(Entities.Role role) { bool isDeleted = false; DbCommand dbCommand = null; try { using (dbCommand = database.GetStoredProcCommand(DBStoredProcedure.DeleteRole)) { database.AddInParameter(dbCommand, "@role_id", DbType.Int32, role.RoleId); database.AddInParameter(dbCommand, "@deleted_by", DbType.Int32, role.DeletedBy); database.AddInParameter(dbCommand, "@deleted_by_ip", DbType.String, role.DeletedByIP); database.AddOutParameter(dbCommand, "@return_value", DbType.Int32, 0); var result = database.ExecuteNonQuery(dbCommand); if (database.GetParameterValue(dbCommand, "@return_value") != DBNull.Value) { isDeleted = Convert.ToBoolean(database.GetParameterValue(dbCommand, "@return_value")); } } } catch (Exception e) { throw e; } finally { dbCommand = null; } return(isDeleted); }
public bool RemoveTaskFromRole(Entities.Role role, Entities.Task task) { bool res = false; using (SqlConnection cnn = new SqlConnection(sqlCnnStr)) { string query = "DELETE FROM RoleTasks" + " WHERE RoleId = @RoleId AND TaskId = @TaskId"; using (SqlCommand cmd = new SqlCommand(query, cnn)) { cmd.CommandType = CommandType.Text; cmd.Parameters.Add(new SqlParameter("@TaskId", task.Id)); cmd.Parameters.Add(new SqlParameter("@RoleId", role.Id)); cnn.Open(); int affected = cmd.ExecuteNonQuery(); res = (affected > 0); } } return(res); }
/// <summary> /// Gets a role by id /// </summary> /// <param name="roleId">Specifies the id of a role.</param> /// <returns>An object representing the role</returns> public Entities.Role GetRoleDetailsById(Int32 roleId) { var role = new Entities.Role(); DbCommand dbCommand = null; using (dbCommand = database.GetStoredProcCommand(DBStoredProcedure.GetRoleDetailsById)) { database.AddInParameter(dbCommand, "@role_id", DbType.Int32, roleId); using (IDataReader reader = database.ExecuteReader(dbCommand)) { while (reader.Read()) { var _role = new Entities.Role { RoleId = DRE.GetNullableInt32(reader, "role_id", 0), RoleName = DRE.GetNullableString(reader, "role_name", null), RoleDesc = DRE.GetNullableString(reader, "role_desc", null) }; role = _role; } } } return(role); }
public IActionResult Get(string name) { Role _role = new Entities.Role(); _role.Id = 0; _role.Name = "User"; String result = "User"; try { List <Role> _roles = _userRepository.GetUserRoles(name).ToList(); foreach (Role role in _roles) { if (role.Name == "Admin") { _role = role; } } } catch (Exception ex) { _loggingRepository.Add(new Error() { Message = ex.Message, StackTrace = ex.StackTrace, DateCreated = DateTime.Now }); _loggingRepository.Commit(); } return(new ObjectResult(_role)); }
public bool Update(Entities.Role role) { bool res = false; using (SqlConnection cnn = new SqlConnection(sqlCnnStr)) { string query = "UPDATE Roles" + " SET RoleName = @RoleName, RolePriority = @RolePriority" + " WHERE " + " RoleId = @RoleId;"; using (SqlCommand cmd = new SqlCommand(query, cnn)) { cmd.CommandType = CommandType.Text; cmd.Parameters.Add(new SqlParameter("@RoleName", role.Name)); cmd.Parameters.Add(new SqlParameter("@RolePriority", role.Priority)); cmd.Parameters.Add(new SqlParameter("@RoleId", role.Id)); cnn.Open(); int affected = cmd.ExecuteNonQuery(); res = (affected > 0); } } return(res); }
public List <Entities.Role> GetRoles() { using (MySql.Data.MySqlClient.MySqlCommand cmd = new MySql.Data.MySqlClient.MySqlCommand("SELECT roles.ID, roles.Description FROM roles", con)) { List <Entities.Role> roles = new List <Entities.Role>(); try { con.Open(); MySqlDataReader reader = cmd.ExecuteReader(); while (reader.Read()) { Entities.Role role = new Entities.Role(); role.RoleID = (int)reader["ID"]; role.Description = (string)reader["Description"]; if (role.Description != "Administrator") { roles.Add(role); } } con.Close(); } catch (Exception ex) { throw new Exception(ex.Message); } return(roles); } }
/// <summary> /// Creates a new instance of a Role. /// </summary> /// <returns>The new Role instance. </returns> public static Entities.Role Factory() { OnCreating(); Entities.Role role = new Entities.Role(); OnCreated(role); return(role); }
private Role CreateRole(string name) { Entities.Role result = new Entities.Role { Name = name }; MtfDatabase.Roles.Add(result); return(result); }
public Role(Entities.Role role) { Create = role.Create; Read = role.Read; Update = role.Update; Delete = role.Delete; Special = role.Special; }
public static void Seed(AppDbContext context) { if (!context.Roles.Any()) { var roles = new List <Entities.Role>(); foreach (var item in (Role[])Enum.GetValues(typeof(Role))) { var role = new Entities.Role { Name = item.ToString(), NormalizedName = item.ToString().ToUpper(), Claims = new List <Entities.RoleClaim>() }; switch (role.Name) { case nameof(Role.Admin): foreach (var claim in (Organization[])Enum.GetValues(typeof(Organization))) { role.Claims.Add(new Entities.RoleClaim { ClaimType = claim.GetType().Name, ClaimValue = claim.ToString() }); } foreach (var claim in (Plant[])Enum.GetValues(typeof(Plant))) { role.Claims.Add(new Entities.RoleClaim { ClaimType = claim.GetType().Name, ClaimValue = claim.ToString() }); } break; case nameof(Role.OrganizationOwner): foreach (var claim in (Organization[])Enum.GetValues(typeof(Organization))) { role.Claims.Add(new Entities.RoleClaim { ClaimType = claim.GetType().Name, ClaimValue = claim.ToString() }); } foreach (var claim in (Plant[])Enum.GetValues(typeof(Plant))) { role.Claims.Add(new Entities.RoleClaim { ClaimType = claim.GetType().Name, ClaimValue = claim.ToString() }); } break; case nameof(Role.PlantOwner): foreach (var claim in (Plant[])Enum.GetValues(typeof(Plant))) { role.Claims.Add(new Entities.RoleClaim { ClaimType = claim.GetType().Name, ClaimValue = claim.ToString() }); } break; } roles.Add(role); } context.Roles.AddRange(roles); context.SaveChanges(); } }
public async Task <Response> Handle(Request request, CancellationToken cancellationToken) { var novaRole = new Entities.Role(request.Nome, request.Descricao); _roleWriteRepository.Add(novaRole); await _uow.CommitAsync(); return(new Response(novaRole)); }
public string ChangeRole(Entities.User LoggedInuser, Entities.Role role) { if (LoggedInuser.RoleID != 0) { MySql.Data.MySqlClient.MySqlCommand Using; Using = new MySql.Data.MySqlClient.MySqlCommand("UPDATE rights set rights.ShowAllDeseases=@ShowAllDeseases,rights.ShowAllMedications=@ShowAllMedications,rights.ShowAllRapports=@ShowAllRapports,rights.ShowAllTherapies=@ShowAllTherapies,rights.ShowNewDesease=@ShowNewDesease,rights.ShowNewMedication=@ShowNewMedication,rights.ShowNewRapport=@ShowNewRapport,rights.ShowNewTherapy=@ShowNewTherapy,rights.ShowOwnDeseases=@ShowOwnDeseases,rights.ShowOwnMedication=@ShowOwnMedication,rights.ShowOwnRapports=@ShowOwnRapports,rights.ShowOwnTherapies=@ShowOwnTherapies,rights.ChangeClientNAW=@Management,rights.ShowNewFile=@shownewfile, rights.ShowAllFiles=@showallfiles,rights.ShowOwnFiles=@showownfiles,rights.ShowClientData=@showclientdata where rights.ID=@roleID", con); using (MySql.Data.MySqlClient.MySqlCommand cmd = Using) { try { cmd.Parameters.AddWithValue("@desc", role.Description ?? throw new Exception("Rol beschrijving is leeg in ChangeRole()")); if (role.RoleID != 0) { cmd.Parameters.AddWithValue("@roleID", role.RoleID); } else { throw new Exception("Rol id is 0 in ChangeRole()"); } cmd.Parameters.AddWithValue("@ShowAllDeseases", role.ShowAllDeseases); cmd.Parameters.AddWithValue("@ShowAllMedications", role.ShowAllMedications); cmd.Parameters.AddWithValue("@ShowAllRapports", role.ShowAllRapports); cmd.Parameters.AddWithValue("@ShowAllTherapies", role.ShowAllTherapies); cmd.Parameters.AddWithValue("@ShowNewDesease", role.ShowNewDesease); cmd.Parameters.AddWithValue("@ShowNewMedication", role.ShowNewMedication); cmd.Parameters.AddWithValue("@ShowNewRapport", role.ShowNewRapport); cmd.Parameters.AddWithValue("@ShowNewTherapy", role.ShowNewTherapy); cmd.Parameters.AddWithValue("@ShowOwnDeseases", role.ShowOwnDeseases); cmd.Parameters.AddWithValue("@ShowOwnMedication", role.ShowOwnMedication); cmd.Parameters.AddWithValue("@ShowOwnRapports", role.ShowOwnRapports); cmd.Parameters.AddWithValue("@ShowOwnTherapies", role.ShowOwnTherapies); cmd.Parameters.AddWithValue("@Management", role.Management); cmd.Parameters.AddWithValue("@shownewfile", role.ShowNewFile); cmd.Parameters.AddWithValue("@showownfiles", role.ShowOwnFiles); cmd.Parameters.AddWithValue("@showallfiles", role.ShowAllFiles); cmd.Parameters.AddWithValue("@showclientdata", role.ShowClientData); con.Open(); cmd.ExecuteNonQuery(); return("Succesvol opgeslagen"); } catch (Exception ex) { if (con.State != System.Data.ConnectionState.Closed) { con.Close(); } return("FOUT: " + ex.Message); } } } else { return("Not allowed to perform this action"); } }
public Role(Entities.Role role, bool detail) : this(role) { if (detail) { this.AccountRoles = role.AccountRoles.Select(ac => new AccountRole(ac)).ToList(); this.Permissions = role.Permissions.Select(p => new Permission(p)).ToList(); } }
protected void btnSave_Click(object sender, ImageClickEventArgs e) { Int32 records = -1; if (validateData()) { Entities.UserSystem oUser = new Entities.UserSystem(); Entities.Program oProgram = new Entities.Program(); Entities.Role oRole = new Entities.Role(); oUser.code = Convert.ToInt32(txtCode.Text); oUser.id = txtId.Text; oUser.name = txtName.Text; oUser.lastName = txtLastName.Text; oUser.homePhone = txtHomePhone.Text; oUser.cellPhone = txtCellPhone.Text; oUser.email = txtEmail.Text; oProgram.code = Convert.ToInt16(cboProgram.SelectedValue); if(oProgram.code == 0) { oProgram.code = 1; } oUser.Password = txtId.Text; oRole.Role_Id = Convert.ToInt16(cboRole.SelectedValue); oUser.oProgram = oProgram; oUser.oRole = oRole; oUser.state = Convert.ToInt16(cboState.SelectedValue); if (BLL.UserSystemBLL.getInstance().exists(oUser.code)) { records = BLL.UserSystemBLL.getInstance().modify(oUser); } else { records = BLL.UserSystemBLL.getInstance().insert(oUser); if (records > 0) { Entities.Email oEmail = new Entities.Email(); String body = messageDesign(oUser.email); oEmail.correoContacto(oUser.email, body, "Bienvenido a Siscape"); } } blockControls(); loadData(); if (records > 0) { lblMessage.Text = "Datos almacenados correctamente."; } //no c para que es esto else { ScriptManager.RegisterStartupScript(Page, Page.GetType(), "comboBox", "comboBox();", true); } } }
public RoleConsistentValidation(Entities.Role person) { BaseValidation = new BaseValidation(); var nameSpecification = new NameIsNotNullSpecification(); BaseValidation.AddSpecification("Name-Specification", nameSpecification.IsSatisfyedBy(person), "Name is null."); }
public async Task <bool> RemoveRoleOfUser(Entities.Role role, Entities.Usuario user) { Entities.RolesUsuario rolesUsuario = new RolesUsuario() { Role = role, Usuario = user }; _userRepository.RemoveRoleOfUser(rolesUsuario); var result = await _unitOfWork.CompleteAsync(); return(result); }
internal static Role ToDto(Entities.Role role) { if (role == null) { return(null); } return(new Role { Id = role.Id, Name = role.Name }); }
public Role(Entities.Role role, bool withPermission, bool withAccountRole) : this(role) { if (withPermission) { this.Permissions = role.Permissions.Select(p => new Permission(p)).ToList(); } if (withAccountRole) { this.AccountRoles = role.AccountRoles.Select(ac => new AccountRole(ac)).ToList(); } }
public long CreateOrUpdateRole(Entities.Role role) { try { UserBC RoleBC = new UserBC(); RoleBC.CreateOrUpdateRole(role); return(role.Id); } catch (Exception ex) { throw; } finally { } }
public Entities.Role GetUserRights(Entities.User user) { using (MySql.Data.MySqlClient.MySqlCommand cmd = new MySql.Data.MySqlClient.MySqlCommand("Select user.RoleID, rights.ShowOwnDeseases, rights.ShowOwnTherapies, rights.ShowAllDeseases, rights.ShowAllTherapies, rights.ShowNewTherapy, rights.ShowNewDesease, rights.ShowNewMedication, rights.ShowOwnMedication, rights.ShowNewRapport, rights.ShowOwnRapports, rights.ShowAllRapports, rights.ChangeClientNAW, rights.ShowAllMedications, rights.ShowOwnFiles,rights.ShowAllFiles,rights.ShowNewFile,rights.ShowClientData, roles.Description from user inner join roles on roles.ID = user.RoleID inner join rights on rights.ID= roles.RightsID where user.BsnNumber=@bsnnummer and user.UniqueID=@uniqueid", con)) { Entities.Role role = new Entities.Role(); cmd.Parameters.AddWithValue("@bsnnummer", user.BsnNumber ?? throw new Exception("BSN nummer is leeg")); if (user.UniqueUserID == null) { throw new Exception("uniek id is leeg"); } else { cmd.Parameters.AddWithValue("@uniqueid", user.UniqueUserID); } try { con.Open(); MySqlDataReader reader = cmd.ExecuteReader(); while (reader.Read()) { role.Description = (string)reader["Description"]; role.ShowOwnDeseases = (bool)reader["ShowOwnDeseases"]; role.ShowOwnTherapies = (bool)reader["ShowOwnTherapies"]; role.ShowAllDeseases = (bool)reader["ShowAllDeseases"]; role.ShowAllTherapies = (bool)reader["ShowAllTherapies"]; role.ShowNewTherapy = (bool)reader["ShowNewTherapy"]; role.ShowNewDesease = (bool)reader["ShowNewDesease"]; role.ShowNewMedication = (bool)reader["ShowNewMedication"]; role.ShowOwnMedication = (bool)reader["ShowOwnMedication"]; role.ShowNewRapport = (bool)reader["ShowNewRapport"]; role.ShowOwnRapports = (bool)reader["ShowOwnRapports"]; role.ShowAllRapports = (bool)reader["ShowAllRapports"]; role.Management = (bool)reader["ChangeClientNAW"]; role.ShowAllMedications = (bool)reader["ShowAllMedications"]; role.ShowNewFile = (bool)reader["ShowNewFile"]; role.ShowAllFiles = (bool)reader["ShowAllFiles"]; role.ShowOwnFiles = (bool)reader["ShowOwnFiles"]; role.ShowClientData = (bool)reader["ShowClientData"]; } con.Close(); } catch (Exception ex) { throw new Exception(ex.Message); } return(role); } }
public Role(Entities.Role role) { this.Code = role.Code; this.Name = role.Name; this.Description = role.Description; this.Status = role.Status; this.Type = role.Type; this.TypeCode = role.Type.AsInt(); this.TypeDescription = role.Type.GetDescription(); this.Store = new Store() { Code = role.Store.Code, Name = role.Store.Name, IsMain = role.Store.IsMain }; }