Example #1
0
 public BaseResult DeleteInstanceRole(DeleteArg arg)
 {
     var role = Db.GetById<Role>(arg.Id);
     if (role == null)
         return new AddUpdateEntityResult { ErrorMessage = Messages.RoleNotFound };
     if (role.RoleType != (int)SystemRoles.None)
         return new AddUpdateEntityResult { ErrorMessage = Messages.RoleDisabledToDelete };
     if (Db.ExistsUsersLinkedToRole(arg.Id))
         return new AddUpdateEntityResult { ErrorMessage = Messages.RoleDisabledToDelete };
     using (var transaction  = new TransactionScope())
     {
         foreach (var componentsToRole in Db.GetComponentRoles(role.RoleId))
         {
             Db.Delete(componentsToRole, arg.Reason);
         }
         Db.Delete(role, arg.Reason);
         transaction.Complete();
         return new BaseResult();
     }
 }
 public ChangePermissionsResult DeleteRole(DeleteArg arg)
 {
     return SendPostRequest<ChangePermissionsResult, DeleteArg>("deleteRole", arg);
 }
Example #3
0
 public DeleteUserCompanyResult DeleteUserToCompany(DeleteArg arg)
 {
     var userCompany = Db.GetUserCompanyById(arg.Id);
     if(userCompany == null)
         return new DeleteUserCompanyResult { ErrorMessage = Messages.UserCompanyNotFound };
     Db.DeleteUserRoles(userCompany.UserId, string.Empty);
     Db.DeleteUserCompany(arg.Id, arg.Reason);
     return new DeleteUserCompanyResult { CompanyId = userCompany.LinkedCompanyId, UserId = userCompany.UserId};
 }