public IActionResult Get() { try { return(Ok(_exampleRepository.GetAll().Select(x => Mapper.Map <MyModelViewModel>(x)))); } catch (Exception exception) { //logg exception or do anything with it return(StatusCode((int)HttpStatusCode.InternalServerError)); } }
public IActionResult ObtainExampleEntities() { try { var result = _repository.GetAll(); if (!result.Any()) { return(NoContent()); } return(Ok(result.ToList())); } catch (Exception exception) { return(StatusCode(500, exception)); } }
public async Task GetAll_Should_ReturnAllExamples() { var examples = new List <Example> { new Example { Id = Guid.NewGuid(), Name = "test1" }, new Example { Id = Guid.NewGuid(), Name = "test2" } }; await _context.Examples.AddRangeAsync(examples); await _context.SaveChangesAsync(); var result = await _exampleRepository.GetAll(); result.Count.Should().Be(examples.Count); result.Should().Contain(examples[0]); result.Should().Contain(examples[1]); }
public IEnumerable <ExampleModel> GetExampleModels() { return(_repository.GetAll()); }
public IEnumerable <Example> Get() { return(_exampleRepository.GetAll()); }