コード例 #1
0
 public IList <MenuItem> GetMenuItems()
 {
     Condition.WithExceptionOnFailure <InvalidParameterException>()
     .Requires(_menuItemRepository, "_menuItemRepository")
     .IsNotNull();
     return(_menuItemRepository.GetAll());
 }
コード例 #2
0
        public ActionResult Index()
        {
            ViewBag.ModelIsNotValid = TempData["ModelIsNotValid"];
            var menuItems = _repository.GetAll().ToList();

            return(View("Index", menuItems));
        }
コード例 #3
0
 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());
     }
 }
コード例 #5
0
 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());
     }
 }
コード例 #6
0
ファイル: AddMenuItemsHandler.cs プロジェクト: vanbinh85/cafe
        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));
        }
コード例 #7
0
        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>());
        }
コード例 #8
0
 public List <MenuItem> GetAll()
 {
     return(repository.GetAll());
 }
コード例 #9
0
 public List <MenuItem> GetAll()
 {
     return(_repo.GetAll());
 }
コード例 #10
0
ファイル: MenuItemService.cs プロジェクト: yougayuki/CmsCore
        public IEnumerable <MenuItem> GetMenuItems()
        {
            var menuItems = menuItemRepository.GetAll();

            return(menuItems);
        }
コード例 #11
0
 public IList <MenuItem> GetAll()
 {
     return(_menuItemRepository.GetAll());
 }