public async Task <Guid> EditAsync(Guid id, RoleDto creationDto)
        {
            var entity = await _entity.SingleOrDefaultAsync(r => r.Id == id);

            if (entity == null)
            {
                throw new InvalidOperationException("Can not find object with this Id.");
            }
            foreach (PropertyInfo propertyInfo in creationDto.GetType().GetProperties())
            {
                string key = propertyInfo.Name;
                if (key != "Id" && entity.GetType().GetProperty(key) != null)
                {
                    entity.GetType().GetProperty(key).SetValue(entity, propertyInfo.GetValue(creationDto, null));
                }
            }
            entity.NormalizedName = creationDto.Name.ToUpper();

            _entity.Update(entity);
            var updated = await _context.SaveChangesAsync();

            if (updated < 1)
            {
                throw new InvalidOperationException("Database context could not update data.");
            }
            return(id);
        }
        public async Task <Guid> CreateAsync(RoleDto creationDto)
        {
            RoleEntity createdRole = Activator.CreateInstance <RoleEntity>();

            foreach (PropertyInfo propertyInfo in creationDto.GetType().GetProperties())
            {
                if (createdRole.GetType().GetProperty(propertyInfo.Name) != null)
                {
                    createdRole.GetType().GetProperty(propertyInfo.Name).SetValue(createdRole, propertyInfo.GetValue(creationDto, null));
                }
            }

            await _roleManager.CreateAsync(createdRole);

            return(createdRole.Id);
        }
        public void RoleDto_Property_Count()
        {
            var role = new RoleDto();

            Assert.AreEqual(5, role.GetType().GetProperties().Count());
        }