Beispiel #1
0
        public void Delete(int id, long currentUserId)
        {
            try
            {
                var user = _newRepository.GetAll().FirstOrDefault(p => p.Id == id && p.UserId == currentUserId);
                if (user == null)
                {
                    throw new ServiceException("You don`t have permissions to make this action!");
                }

                _logger.Info("Start deleting article with id " + id);
                _newRepository.Delete(p => p.Id == id);
                _logger.Info("Delete Article with id " + id);
            }
            catch (RepositoryException re)
            {
                throw new ServiceException("Repository ex: " + re.Message);
            }
            catch (Exception ex)
            {
                throw new ServiceException(ex.Message);
            }
        }
Beispiel #2
0
 public IEnumerable <New> GetAll()
 {
     return(_newRepository.GetAll());
 }