Пример #1
0
        public async Task AddTest()
        {
            var fake           = Mock.Of <IHistoryR>();
            var historyService = new HistoryService(fake);

            var history = new History()
            {
                CardId = 1, BookId = 1
            };
            await historyService.AddAndSave(history);
        }
Пример #2
0
        public async Task <IActionResult> Create([Bind("Id,CardId,BookId")] History history)
        {
            if (ModelState.IsValid)
            {
                await _historyService.AddAndSave(history);

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["BookId"] = new SelectList(_historyService.getBooks(), "Id", "Id", history.BookId);
            ViewData["CardId"] = new SelectList(_historyService.getCard(), "Id", "Id", history.CardId);
            return(View(history));
        }