Esempio n. 1
0
        public void Delete(int id)
        {
            _log.LogInformation($"Searching projection {id}");
            HireProjection hireProjection = _hireProjectionRepository.Query().Where(_ => _.Id == id).FirstOrDefault();

            if (hireProjection == null)
            {
                throw new DeleteHireProjectionNotFoundException(id);
            }
            _log.LogInformation($"Deleting hireProjection {id}");
            _hireProjectionRepository.Delete(hireProjection);

            _unitOfWork.Complete();
        }
Esempio n. 2
0
 private void ValidateExistence(int id, int month, int year)
 {
     try
     {
         HireProjection hireProjection = _hireProjectionRepository.Query().Where(_ => _.Month == month && _.Year == year && _.Id != id).FirstOrDefault();
         if (hireProjection != null)
         {
             throw new InvalidHireProjectionException("The HireProjection already exists .");
         }
     }
     catch (ValidationException ex)
     {
         throw new CreateContractInvalidException(ex.ToListOfMessages());
     }
 }