コード例 #1
0
ファイル: BookController.cs プロジェクト: Ahmed-10/BookStore
        public ActionResult Edit(int id, BookAutherViewModel viewModel)
        {
            try
            {
                // TODO: Add update logic here

                string fileName = ChangeFile(viewModel.File, viewModel.imgUrl);

                var  auther = autherRepository.Find(viewModel.AutherID);
                Book book   = new Book
                {
                    id          = viewModel.BookID,
                    Title       = viewModel.Title,
                    Description = viewModel.Description,
                    _auther     = auther,
                    imgURL      = fileName
                };

                bookRepository.Update(id, book);
                return(RedirectToAction(nameof(Index)));
            }
            catch (Exception e)
            {
                return(View());
            }
        }
コード例 #2
0
 public ActionResult Edit(int id, Auther auther)
 {
     try
     {
         // TODO: Add update logic here
         autherReposetory.Update(id, auther);
         return(RedirectToAction(nameof(Index)));
     }
     catch
     {
         return(View());
     }
 }