public ActionResult Create(BookAutherViewModel model) { if (ModelState.IsValid) { try { if (model.AutherID == -1) { ViewBag.Message = "Please Select an Auther"; return(View(GetAllAuthers())); } DeleteFile(model.imgUrl); string fileName = UploadFile(model.File); var auther = autherRepository.Find(model.AutherID); // TODO: Add insert logic here Book book = new Book { Title = model.Title, Description = model.Description, _auther = auther, imgURL = fileName }; bookRepository.Add(book); return(RedirectToAction(nameof(Index))); } catch { return(View()); } } ModelState.AddModelError("", "You have to fill all the required fields!"); return(View(GetAllAuthers())); }
// GET: Book/Details/5 public ActionResult Details(int id) { var book = bookRepository.Find(id); return(View(book)); }
// GET: Auther/Details/5 public ActionResult Details(int id) { var auther = autherReposetory.Find(id); return(View(auther)); }