Exemple #1
0
        public IActionResult Index()
        {
            List <Author>       A  = Repo.GetAllAuthors();
            AuthorListViewModel VM = new AuthorListViewModel();

            foreach (Author a in A)
            {
                VM.Authors.Add(Converter.AuthorToAuthorViewModel(a));
            }
            return(View(VM));
        }
Exemple #2
0
        public async Task <IActionResult> Create(BookViewModel vm)
        {
            vm.FileLoc = await UploadFile(vm.File);

            vm.BookAuthor = AuthorConverter.AuthorToAuthorViewModel(AuthorRepo.GetAuthorByID(vm.Author));
            Book B  = BookConverter.BookViewModelToBook(vm);
            int  ID = BookRepo.InsertBook(B);

            if (ID != 0)
            {
                return(RedirectToAction("Detail", new { Id = ID }));
            }
            else
            {
                return(RedirectToAction("Create"));
            }
        }