Esempio n. 1
0
        public async Task <int> CreateAsync(DTO.PermissionRequest newPermission)
        {
            var permission = _mapper.Map <Permission>(newPermission);

            await _repository.AddPermissionAsync(permission);

            await _repository.SaveAsync();

            return(permission.Id);
        }
Esempio n. 2
0
        public async Task UpdateAsync(int id, DTO.PermissionRequest updatedPermission)
        {
            var permission = await _repository.GetPermissionForUpdateAsync(id);

            if (permission == null)
            {
                throw new EntityNotFoundException(NotFoundMsg);
            }

            _mapper.Map(updatedPermission, permission);

            _repository.UpdatePermission(permission);

            await _repository.SaveAsync();
        }