コード例 #1
0
        public async Task <IActionResult> Create([Bind("ID,author,releaseDate,price")] BookModel bookModel)
        {
            if (ModelState.IsValid)
            {
                _context.Add(bookModel);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(bookModel));
        }
コード例 #2
0
ファイル: MainFrame.cs プロジェクト: sjbwylbs/TextReader
        /// <summary>
        /// 打开小说
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void tsOpen_Click(object sender, EventArgs e)
        {
            //打开对话框
            DialogResult dr = openFileDialog1.ShowDialog();

            if (dr == DialogResult.OK)
            {
                FileInfo fi = new FileInfo(openFileDialog1.FileName);

                tb = TextBook.NewTextBook(fi.FullName, cacheDir);

                //查找是否有缓存的章节目录
                if (File.Exists(tb.CatalogsFileName))
                {
                    //如果存在则导入
                    tb = TextBook.Restore(tb.CatalogsFileName);
                }
                else
                {
                    //如果不存在则生成目录章节
                    TextBook.NewCatalog(ref tb);
                    TextBook.Save(tb);
                }

                //显示书名和作者
                this.Text = string.Format(APPLICATION_CAPTION, tb.Author, "-" + tb.BookName, "        ");


                bs.Add(tb);
                ToolStripMenuItem item = new ToolStripMenuItem(tb.BookName);
                item.Click += new EventHandler(Books_Click);
                this.tsBooks.DropDownItems.Add(item);

                GenCategoriesMenu();
            }
        }