public IList <MenuItem> GetMenuItems() { Condition.WithExceptionOnFailure <InvalidParameterException>() .Requires(_menuItemRepository, "_menuItemRepository") .IsNotNull(); return(_menuItemRepository.GetAll()); }
public ActionResult Index() { ViewBag.ModelIsNotValid = TempData["ModelIsNotValid"]; var menuItems = _repository.GetAll().ToList(); return(View("Index", menuItems)); }
public IActionResult GetAllMenuItems() { try { IEnumerable <MenuItem> Vlist = _IMenuItemRepository.GetAll(); return(Ok(Vlist)); } catch { return(new NoContentResult()); } }
public IActionResult GetAllMenuItems() { try { _log4net.Info("Getting all menu items"); var list = repository.GetAll().ToList(); return(Ok(list)); } catch { _log4net.Error("Failed to get menu items"); return(new NoContentResult()); } }
public IActionResult Get() { try { _log4net.Info(" Http GET is accesed"); IEnumerable <MenuItem> menulist = _menuItemRepository.GetAll(); return(Ok(menulist)); } catch { _log4net.Error("Error in Get request"); return(new NoContentResult()); } }
private async Task <Option <Unit, Error> > CheckIfNumbersAreNotConflicting(IEnumerable <int> itemNumbersToCheck) { var numbersLookup = itemNumbersToCheck .Distinct() .ToArray(); var conflictingNumbers = (await _menuItemRepository .GetAll(i => numbersLookup.Contains(i.Number))) .Select(i => i.Number) .ToArray(); return(conflictingNumbers .SomeWhen( numbers => numbers.Length == 0, Error.Conflict($"Item numbers {string.Join(", ", conflictingNumbers)} are already taken.")) .Map(_ => Unit.Value)); }
public async Task <Option <IList <MenuItem>, Error> > ItemsShouldExist(IList <int> menuItemNumbers) { var allMenuItems = (await _menuItemRepository .GetAll()) // Purposefully not using a lookup to avoid possible unique key exceptions // since we should never have items with conflicting menu numbers .ToDictionary(x => x.Number); var itemsToServeResult = menuItemNumbers .Select(menuNumber => allMenuItems .GetValueOrNone(menuNumber) .WithException(Error.NotFound($"Menu item with number {menuNumber} was not found."))) .ToList(); var errors = itemsToServeResult .Exceptions() .SelectMany(e => e.Messages) .ToArray(); return(errors.Any() ? Option.None <IList <MenuItem>, Error>(Error.NotFound(errors)) : itemsToServeResult.Values().ToList().Some <IList <MenuItem>, Error>()); }
public List <MenuItem> GetAll() { return(repository.GetAll()); }
public List <MenuItem> GetAll() { return(_repo.GetAll()); }
public IEnumerable <MenuItem> GetMenuItems() { var menuItems = menuItemRepository.GetAll(); return(menuItems); }
public IList <MenuItem> GetAll() { return(_menuItemRepository.GetAll()); }