Ejemplo n.º 1
0
        public void Delete(int id)
        {
            _log.LogInformation($"Searching casualty {id}");
            EmployeeCasualty employeeCasualty = _employeeCasualtyRepository.Query().Where(_ => _.Id == id).FirstOrDefault();

            if (employeeCasualty == null)
            {
                throw new DeleteEmployeeCasualtyNotFoundException(id);
            }
            _log.LogInformation($"Deleting employeeCasualty {id}");
            _employeeCasualtyRepository.Delete(employeeCasualty);

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