public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Book book = db.Books.Find(id);

            if (book == null)
            {
                return(HttpNotFound());
            }
            IQueryable <Author> a = db.Authors.OrderBy(d => d.ID);
            var vm = new BookVM();

            vm.Book      = book;
            vm.AuthNames = new List <SelectListItem>();
            foreach (Author da in a.ToList())
            {
                SelectListItem selectList = new SelectListItem()
                {
                    Text     = da.FullName,
                    Value    = da.ID.ToString(),
                    Selected = da.ID == book.Author.ID
                };

                vm.AuthNames.Add(selectList);
            }
            return(View(vm));
        }
        public ActionResult Create()
        {
            IQueryable <Author> a = db.Authors.OrderBy(d => d.ID);
            var vm = new BookVM();

            vm.AuthNames = new List <SelectListItem>();
            foreach (Author da in a.ToList())
            {
                SelectListItem selectList = new SelectListItem()
                {
                    Text     = da.FullName,
                    Value    = da.ID.ToString(),
                    Selected = false
                };

                vm.AuthNames.Add(selectList);
            }
            return(View("Create", vm));
        }