public PublisherOutput Get(int id) { try { var publisher = new GetDeletePublisherInput { Id = id }; var validationResults = _getDeletePublisherValidator.Validate(publisher, "Id"); if (!validationResults.IsValid) { throw new ValidationException(validationResults.Errors); } var query = _unitOfWork.GetPublishers().Get(id); return(Mapper.Map <PublisherOutput>(query)); } catch (ValidationException exception) { _logger.Debug(exception.Message); throw; } catch (Exception exception) { _logger.Trace(exception.StackTrace); throw; } }
public PublisherOutput GetByCompanyName(string companyName) { try { var publisher = new GetDeletePublisherInput { CompanyName = companyName }; var validationResults = _getDeletePublisherValidator.Validate(publisher, "CompanyName"); if (!validationResults.IsValid) { throw new ValidationException(validationResults.Errors); } var query = _unitOfWork.GetPublishers().Find(_ => _.CompanyName == companyName).FirstOrDefault(); return(Mapper.Map <PublisherOutput>(query)); } catch (ValidationException exception) { _logger.Debug(exception.Message); throw; } catch (Exception exception) { _logger.Trace(exception.StackTrace); throw; } }
public void Delete(int id) { try { var publisher = new GetDeletePublisherInput { Id = id }; var validationResults = _getDeletePublisherValidator.Validate(publisher, "Id"); if (!validationResults.IsValid) { throw new ValidationException(validationResults.Errors); } _unitOfWork.GetPublishers().Delete(id); _unitOfWork.Save(); } catch (ValidationException exception) { _logger.Debug(exception.Message); throw; } catch (Exception exception) { _logger.Trace(exception.StackTrace); throw; } }