public void GetAllTest() { GrantFollowerPermissions(); sportsStorage.Setup(r => r.GetAll()).Returns(new List <Sport>() { testSport, testSport, testSport }); ICollection <SportDto> result = serviceToTest.GetAllSports(); authentication.Verify(r => r.Authenticate(), Times.Once); authentication.Verify(r => r.AuthenticateAdmin(), Times.Never); sportsStorage.Verify(r => r.GetAll(), Times.Once); Assert.AreEqual(3, result.Count); }
private IActionResult TryGetAll() { ICollection <SportDto> allOfThem = sports.GetAllSports(); IEnumerable <SportModelOut> output = allOfThem.Select(s => CreateModelOut(s)); return(Ok(output)); }
public ActionResult <List <SportDto> > GetAllSports() { var sports = _sportService.GetAllSports().Select(s => new SportDto { Id = s.Id, Name = s.Name }).ToList(); return(Ok(sports)); }
public async Task <ActionResult <IEnumerable <SportDTO> > > GetAllSports() { try { return(Ok(await _sportService.GetAllSports())); } catch (Exception exception) { return(BadRequest(exception.Message)); } }
public IActionResult Sports(string search) { ViewData["CurrentFilter"] = search; var sports = _sportService.GetAllSports(); if (!String.IsNullOrEmpty(search)) { var searchToUpper = search.ToUpper(); sports = sports.Where(u => u.Name.ToUpper().Contains(searchToUpper)); } return(View(sports)); }
public IActionResult Get() { IEnumerable <Sport> sports = sportService.GetAllSports(); if (sports.Count() > 0) { List <SportModelOut> modelsOut = new List <SportModelOut>(); foreach (Sport sport in sports) { SportModelOut model = new SportModelOut(sport); modelsOut.Add(model); } return(Ok(modelsOut)); } return(Ok("No hay deportes ingresados al sistema")); }