public List <ExampleEntity> Get()
        {
            _logger.LogDebug("Get All");
            var result = _repository.Get();

            _logger.LogDebug($"Get All Result: {result.Count} entities");
            return(result.Select(r => _mapper.Map <ExampleEntity>(r)).ToList());
        }
Exemple #2
0
        public ExampleDto Get(Guid newGuid)
        {
            var entity = _exampleRepository.Get(newGuid);
            var dto    = _exampleMapper.Map(entity);

            return(dto);
        }
        public IActionResult Index()
        {
            //we are just returning data and because the domain contains all the business logic we can just get the model
            //and serialize the properties.
            var examples = _exampleRepository.Get(0, 10);

            return(new JsonResult(_mapper.Map <List <ExampleDto> >(examples)));
        }
Exemple #4
0
        public UpdateExampleResponse Process(UpdateExampleRequest request)
        {
            try
            {
                var example = _repository.Get(request.Id);

                example.UpdateProperty1(request.Property1);
                if (example.IsValid())
                {
                    _repository.Save(example);
                    return(new UpdateExampleResponse(true));
                }
                else
                {
                    return(new UpdateExampleResponse(false, example.Errors));
                }
            }
            catch (Exception ex)
            {
                var validations = new Validations();
                validations.AddError(ErrorCode.Unexpected, "Unable to update example model.");
                return(new UpdateExampleResponse(false, validations));
            }
        }
 public Example Get(int id)
 {
     return(_exampleRepository.Get(id));
 }
Exemple #6
0
    static void Main(string[] args)
    {
        IExampleRepository repository = CreateDefaultRepository();

        var data = repository.Get();
    }
Exemple #7
0
 public IEnumerable <Example> Get()
 {
     return(repository.Get());
 }