public Role Post(Role request)
		{
			RoleEntity entity = request.TranslateToEntity();

			if (entity.Id == 0)
				entity.Id = GenericRepository.GetMaxIdIncrement<RoleEntity>(AuthAdminDatabase, RolesCollection);

			entity.RootParentId = entity.RootParentId == 0 ? entity.Id : entity.RootParentId;
			entity.ParentId = entity.ParentId == 0 ? entity.Id : entity.ParentId;
			entity = GenericRepository.Add(AuthAdminDatabase, RolesCollection, entity);

			// add to parent child objects
			if (entity.Id != entity.ParentId)
			{
				RoleEntity parentEntity = GenericRepository.GetItemTopById<RoleEntity>(AuthAdminDatabase, RolesCollection,
					entity.ParentId);
				if (parentEntity != null)
				{
					parentEntity.ChildRoleIds.Add(entity.Id);
					parentEntity = GenericRepository.Add(AuthAdminDatabase, RolesCollection, parentEntity);
				}
			}

			return entity.TranslateToResponse();
		}
		public Role Put(Role request)
		{
			RoleEntity currentEntity = GenericRepository.GetItemTopById<RoleEntity>(AuthAdminDatabase, RolesCollection, request.Id);

			RoleEntity entity = request.TranslateToEntity();

			entity = GenericRepository.Add(AuthAdminDatabase, RolesCollection, entity);

			// If parentid different from entity remove from current parent entity and add to new parent entity
			if (currentEntity.ParentId != entity.ParentId)
			{
				//remove from current parent
				RoleEntity currentParentEntity = GenericRepository.GetItemTopById<RoleEntity>(AuthAdminDatabase, RolesCollection, currentEntity.ParentId);
				if (currentParentEntity != null)
				{
					currentParentEntity.ChildRoleIds.Remove(entity.Id);
					currentParentEntity = GenericRepository.Add(AuthAdminDatabase, RolesCollection, currentParentEntity);
				}

				//add to new parent
				RoleEntity parentEntity = GenericRepository.GetItemTopById<RoleEntity>(AuthAdminDatabase, RolesCollection, entity.ParentId);
				if (parentEntity != null)
				{
					parentEntity.ChildRoleIds.Add(entity.Id);
					parentEntity = GenericRepository.Add(AuthAdminDatabase, RolesCollection, parentEntity);
				}
			}

			return entity.TranslateToResponse();
		}