Beispiel #1
0
        public async Task <AccessResponse> DeleteAsync(int code)
        {
            try
            {
                var exist = await _accessRepository.FindByIdAsync(code);

                AccessResponse response = exist == null ? new AccessResponse($"Access {code} not found") : new AccessResponse(exist);

                _accessRepository.Remove(exist);
                await _unitOfWork.CompleteAsync();

                return(response);
            }
            catch (Exception e)
            {
                return(new AccessResponse($"An error occurred when deleting the access: { e.Message }"));
            }
        }
        public bool DeleteAccess(Guid accessId)
        {
            try
            {
                var currentAccess = _accessRepository.FindByID(accessId);

                if (currentAccess == null)
                {
                    return(false);
                }
                else
                {
                    _accessRepository.Remove(accessId);
                }
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
            return(true);
        }