Ejemplo n.º 1
0
 public Role EditRole(Role role)
 {
     // Get original person object from database, no need to assig it to a variable
     GetRole(role.RoleId);
     _entities.Roles.ApplyCurrentValues(role);
     _entities.SaveChanges();
     return role;
 }
Ejemplo n.º 2
0
 public bool DeleteRole(Role role)
 {
     try
     {
         _roleRepository.DeleteRole(role);
     }
     catch
     {
         return false;
     }
     return true;
 }
Ejemplo n.º 3
0
        public bool EditRole(Role role)
        {
            // Validation logic
            if (!ValidateRole(role))
                return false;

            // Database logic
            try
            {
                _roleRepository.EditRole(role);
            }
            catch
            {
                return false;
            }
            return true;
        }
Ejemplo n.º 4
0
 public bool ValidateRole(Role role)
 {
     if (role.Name.Trim().Length == 0)
         _validationDictionary.AddError("RoleName", "Role name is required.");
     return _validationDictionary.IsValid;
 }
Ejemplo n.º 5
0
 public void DeleteRole(Role role)
 {
     var originalPerson = GetRole(role.RoleId);
     _entities.Roles.DeleteObject(role);
     _entities.SaveChanges();
 }
Ejemplo n.º 6
0
 public Role CreateRole(Role role)
 {
     _entities.AddToRoles(role);
     _entities.SaveChanges();
     return role;
 }
 /// <summary>
 /// Deprecated Method for adding a new object to the Roles EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToRoles(Role role)
 {
     base.AddObject("Roles", role);
 }
 /// <summary>
 /// Create a new Role object.
 /// </summary>
 /// <param name="roleId">Initial value of the RoleId property.</param>
 /// <param name="name">Initial value of the Name property.</param>
 public static Role CreateRole(global::System.Int32 roleId, global::System.String name)
 {
     Role role = new Role();
     role.RoleId = roleId;
     role.Name = name;
     return role;
 }