private void button1_Click(object sender, EventArgs e) { Model.Book m_book = new Model.Book(); m_book = getBook(); if(CURRENT_TYPE == 1) { bool result = bll.AddBook(m_book); if(result) { MessageBox.Show("书籍添加成功!"); this.Hide(); this.DialogResult = DialogResult.OK; } else { MessageBox.Show("书籍添加失败...请检查书籍编号"); } } else if (CURRENT_TYPE == 2) { bool result = bll.UpdateBook(m_book); if (result) { MessageBox.Show("书籍更新成功!"); this.Hide(); this.DialogResult = DialogResult.OK; } else { MessageBox.Show("书籍添加失败..."); } } }
public BorrowResult(Model.Viewer _viewer, Model.Book _book, Model.Manager _manager) { InitializeComponent(); viewer = _viewer; book = _book; manager = _manager; RenderData(viewer, book, manager); }
public void AddBook() { Model.Book book = new Model.Book(); book = TestHelper.initBook(); SQLDAL.Book target = new SQLDAL.Book(); bool actual = target.AddBook(book); bool expected = true; Assert.AreEqual(expected, actual); }
public void BorrowVIdErrTest() { Model.Book book = new Model.Book(); Model.Viewer viewer = new Model.Viewer(); Model.Manager manager = new Model.Manager(); book.Id = "book"; viewer.Id = "s000001";//学号错误 manager.Id = "manager"; //bool expected = false; //期望值 //bool actual; int expected = 0; //期望值 Hashtable actual; SQLDAL.Book target = new SQLDAL.Book(); actual = target.Borrow(book, viewer, manager); //实际值 Assert.AreEqual(expected, actual["result"]); }
public static Model.Book CreateBookHeader(string title, long? isbn, double? price, string url) { var b = new Model.Book(); b.Title = title; if (isbn.HasValue) { b.ISBN = isbn.Value; } if (price.HasValue) { b.Price = price.Value; } b.Url = url; return b; }
public void BorrowTest() { Model.Book book = new Model.Book(); Model.Viewer viewer = new Model.Viewer(); Model.Manager manager = new Model.Manager(); book.Id = "book"; viewer.Id = "st"; manager.Id = "manager"; // bool expected = false; //期望值//因为数据库中已经存在这一项数据 所以为false //bool actual; int expected = 0; //期望值//因为数据库中已经存在这一项数据 所以为false Hashtable actual; SQLDAL.Book target = new SQLDAL.Book(); actual = target.Borrow(book, viewer, manager); //实际值 Assert.AreEqual(expected, actual["result"]); }
//----------------------------------------------------------- /// <summary> /// 生成静态页面 id:要生成静态页面的书的编号 /// </summary> public bool CreateHtmlPage(int id) { Model.Book bookModel = dal.GetModel(id); if (bookModel != null) { //找到模板文件. string filePath = HttpContext.Current.Request.MapPath("/Template/BookTemplate.html"); string fileContent = File.ReadAllText(filePath); fileContent = fileContent.Replace("$author", bookModel.Author).Replace("$title", bookModel.Title).Replace("$wordCount", bookModel.WordsCount.ToString()).Replace("$publishDate", bookModel.PublishDate.ToShortDateString()).Replace("$isbn", bookModel.ISBN).Replace("$unitPrice", bookModel.UnitPrice.ToString("0.00")).Replace("$toc", bookModel.TOC).Replace("$content", bookModel.ContentDescription).Replace("$authorDesc", bookModel.AurhorDescription).Replace("$bookId", bookModel.Id.ToString()); string dir = "/BookDetails/" + bookModel.PublishDate.Year + "/" + bookModel.PublishDate.Month + "/" + bookModel.PublishDate.Day + "/"; Directory.CreateDirectory(Path.GetDirectoryName(HttpContext.Current.Request.MapPath(dir))); string fullDir = dir + bookModel.Id + ".html"; File.WriteAllText(HttpContext.Current.Request.MapPath(fullDir), fileContent, System.Text.Encoding.UTF8); return(true); } else { return(false); } }
public void ProcessRequest(HttpContext context) { context.Response.ContentType = "text/plain"; BLL.UserManager userManager = new BLL.UserManager(); if (userManager.ValidateUserLogin())//判断是否登录 { int bookId = Convert.ToInt32(context.Request["bookId"]); //判断数据库中是否有该商品. BLL.BookManager bookManager = new BLL.BookManager(); Model.Book bookModel = bookManager.GetModel(bookId); if (bookModel != null) { int userId = ((Model.User)context.Session["userInfo"]).Id;//获取登录用户登录的ID。 BLL.CartManager cartManager = new BLL.CartManager(); Model.Cart cartModel = cartManager.GetModel(userId, bookId); //如果购物车有该商品,更新数量加1,没有插入 if (cartModel != null) { cartModel.Count = cartModel.Count + 1; cartManager.Update(cartModel); } else { Model.Cart modelCart = new Model.Cart(); modelCart.Count = 1; modelCart.Book = bookModel; modelCart.User = ((Model.User)context.Session["userInfo"]); cartManager.Add(modelCart); } context.Response.Write("ok:商品成功添加到购物车"); } else { context.Response.Write("no:无此商品"); } } else { context.Response.Write("login:没有登录"); } }
/// <summary> /// 将商品的信息生成静态页面 /// </summary> public void CreateHtmlPage(int id) { //根据每一本书的 内容生成一个 静态页面。 Model.Book model = dal.GetModel(id); //获取模板文件 string template = HttpContext.Current.Request.MapPath("/Template/BookTemplate.html"); string fileContent = File.ReadAllText(template); fileContent = fileContent.Replace("$title", model.Title) .Replace("$author", model.Author) .Replace("$unitprice", model.UnitPrice.ToString("0.00")) .Replace("$isbn", model.ISBN) .Replace("$content", model.ContentDescription.Substring(0, 15)) .Replace("$bookId", model.Id.ToString()); string dir = "/HtmlPage/" + model.PublishDate.Year + "/" + model.PublishDate.Month + "/" + model.PublishDate.Day + "/"; Directory.CreateDirectory(Path.GetDirectoryName(HttpContext.Current.Request.MapPath(dir))); string fullDir = dir + model.Id + ".html"; File.WriteAllText(HttpContext.Current.Request.MapPath(fullDir), fileContent, System.Text.Encoding.UTF8); }
public ActionResult TestAddQueue() { Model.Book model = new Model.Book(); model.AuthorDescription = "adsfad"; model.Author = "老赵"; model.CategoryId = 1; model.Clicks = 1; model.ContentDescription = "Asp.Net MVC高级编程"; model.EditorComment = "adfasdf"; model.ISBN = "984598234"; model.PublishDate = DateTime.Now; model.PublisherId = 72; model.TOC = "aaaaaaa"; model.UnitPrice = 22.3m; model.WordsCount = 1234; //先将数据储存到数据库中 //然后再向队列中添加 SearchIndexManager.GetInstance().AddQueue("2323", model.Title, model.ContentDescription); return(Content("ok")); }
private void button1_Click(object sender, EventArgs e) { if (this.textBox1.Text == "") { MessageBox.Show("编码输入不能为空!"); return; } string Uname = this.textBox1.Text.Trim(); Model.Book book = DAL.dalCustom.getSomePhoto(Uname); if (book.bookPhoto == null) { MessageBox.Show("没有图片!"); return; } else { byte[] bookPhoto = (byte[])(book.bookPhoto); MemoryStream ms = new MemoryStream(bookPhoto); pictureBox1.Image = Image.FromStream(ms); } }
/// <summary> /// 向购物车中添加商品信息。 /// </summary> protected void AddCart() { if (!string.IsNullOrEmpty(Request.QueryString["id"])) { int bookId = 0; if (!int.TryParse(Request.QueryString["id"], out bookId)) { Response.Redirect("/showinfo.aspx?msg=" + Server.UrlEncode("参数错误") + "&url=BookList.aspx" + "&txt=" + Server.UrlEncode("返回图书列表")); } else { BLL.BookManager bll = new BookShop.BLL.BookManager(); Model.Book model = bll.GetModel(bookId);//根据传递过来的书的编号查找该书. if (model != null) { BLL.CartManager cartBll = new BookShop.BLL.CartManager(); int userId = ((Model.User)Session["user"]).Id; //得到了当前登录用户的编号. Model.Cart cartModel = cartBll.GetModel(model.Id, userId); //根据用户的编号,与书的编号,找出购物车中的商品项. if (cartModel == null) //如果该条件成立,向购物车表中插入一条记录 { Model.Cart ModelCart = new BookShop.Model.Cart(); ModelCart.User = (Model.User)Session["user"]; ModelCart.Book = model; ModelCart.Count = 1; cartBll.Add(ModelCart); } else//更新该商品项的数量 { cartModel.Count = cartModel.Count + 1; cartBll.Update(cartModel); } } else { Response.Redirect("/showinfo.aspx?msg=" + Server.UrlEncode("该书不存在") + "&url=BookList.aspx" + "&txt=" + Server.UrlEncode("返回图书列表")); } } } }
//EDIT BOOK public Book EditedBook(Model.Book edited) { using (var connection = GetConnection()) { connection.Open(); MySqlCommand command = new MySqlCommand( "UPDATE tanya_project SET author = @a, title = @t, genre = @g, year=@y WHERE id = @id", connection); command.Parameters.AddWithValue("@a", edited.author); command.Parameters.AddWithValue("@t", edited.title); command.Parameters.AddWithValue("@g", edited.genre); command.Parameters.AddWithValue("@y", edited.year); command.Parameters.AddWithValue("@id", edited.id); var numUpdated = command.ExecuteNonQuery(); Console.WriteLine("Updated {0} user records!", numUpdated); return(edited); } }
protected void Page_Load(object sender, EventArgs e) { if (!string.IsNullOrEmpty(Request.QueryString["id"])) { int id = 0; if (!int.TryParse(Request.QueryString["id"], out id)) { Response.Redirect("BookList2.aspx"); } else { BLL.BookManager bll = new BookShop.BLL.BookManager(); Model.Book model = bll.GetModel(id);//根据书的编号,查找该书. if (model != null) { StringBuilder builder = new StringBuilder(); builder.Append("<table border='1' >"); builder.Append("<tr><th width='30px'>书名:</th><td>" + model.Title + "</td></tr>"); builder.Append("<tr><th>封面:</th><td><img src=/Images/BookCovers/" + model.ISBN + ".jpg/></td></tr>"); builder.Append("<tr><th>作者:</th><td>" + model.Author + "</td></tr>"); builder.Append("<tr><th>出版日期::</th><td>" + model.PublishDate.ToShortDateString() + "</td></tr>"); builder.Append("<tr><th>单价:</th><td>¥" + model.UnitPrice.ToString("0.00") + "<a href='cart.aspx?id=" + model.Id + "'><img src='/Images/sale.gif' border='0'/></a></td></tr>"); builder.Append("<tr><th>简介:</th><td>" + model.ContentDescription + "</td></tr>"); builder.Append("<tr><th>目录::</th><td>" + model.TOC + "</td></tr>"); builder.Append("</table>"); strHtml = builder.ToString(); } else { Response.Redirect("/showinfo.aspx?msg=" + Server.UrlEncode("图书部存在") + "&url=/BookList2.aspx" + "&txt=" + Server.UrlEncode("图书列表页面")); } } } else { Response.Redirect("BookList2.aspx"); } }
public async Task <IActionResult> OnGet(int?id) { Book = new Model.Book(); if (!id.HasValue) { //Create return(Page()); } //Update //You can use FindAsync or FirstOrDefaultAsync to get the book from the DB. Book = await _dbContext.Books.FindAsync(id); //Book = await _dbContext.Books.FirstOrDefaultAsync(b => b.Id == id); if (Book == null) { return(NotFound()); } return(Page()); }
public async Task OnGet(int id) { Book = await _db.Book.FindAsync(id); }
public void DeleteBook() { Model.Book book = new Model.Book(); book = TestHelper.initBook(); book.Id = book.Id + "TEST"; //先添加这本书 SQLDAL.Book target = new SQLDAL.Book(); bool actual = target.AddBook(book); bool expected = true; Assert.AreEqual(expected, actual); //删除这本书 bool actual_2 = target.DeleteBook(book); bool expected_2 = true; Assert.AreEqual(expected_2, actual_2); }
public void MulBorrowTest() { Model.Book book = new Model.Book(); Model.Viewer viewer = new Model.Viewer(); Model.Manager manager = new Model.Manager(); book.Id = "9787513318525"; viewer.Id = "st"; manager.Id = "manager"; // bool expected = false; //期望值 //bool actual; int expected = -1; //期望值 已经借过的返回值为-1 Hashtable actual; SQLDAL.Book target = new SQLDAL.Book(); target.Borrow(book, viewer, manager);//第一次借 actual = target.Borrow(book, viewer, manager); //实际值//第二次借 Assert.AreEqual(expected, actual["result"]); //由于系统限制每个人只能借同一本书一次 所以测试时只有第一次是能成功 }
public void UpdateBook() { Model.Book book = new Model.Book(); book = TestHelper.initBook(); book.Id = "DKLFJO2342"; //测试用 SQLDAL.Book target = new SQLDAL.Book(); bool actual = target.UpdateBook(book); bool expected = true; Assert.AreEqual(expected, actual); }
public void ReturnTest() { Model.Book book = new Model.Book(); Model.Viewer viewer = new Model.Viewer(); Model.Manager manager = new Model.Manager(); book.Id = "9787569902921"; viewer.Id = "s001"; manager.Id = "manager"; bool expected = false; //期望值//因为数据库中已经存在这一项数据 所以为false bool actual; SQLDAL.Book target = new SQLDAL.Book(); actual = target.ReturnBook(viewer, book, manager); //实际值 Assert.AreEqual(expected, actual); }
private Book ConvertToGraphQLBook(Model.Book modelBook, bool includeAuthor = false) { var modelAuthor = includeAuthor ? authorsDataSource.GetAuthor(modelBook.AuthorId) : null; return(BookMapper.ConvertModelBookToGraphQLBook(modelBook, modelAuthor)); }
public static void DeleteBook(Model.Book book) { }
public Product(Book b) { book = b; }
public List<Model.Book> GetEnglishBook(Int64 _BookID, Int64 _CategoryID, string _CategoryName, string _Title, string _Author, string _Publisher, string _PublishYear, string _Language, int _Status, int _NewRelease, int _BookFeature, int _EnglishBook, int _Start, int _Limit) { List<Model.Book> lModel = new List<Model.Book>(); try { SqlParameter[] p = { new SqlParameter("@BookID", SqlDbType.Int, 4), new SqlParameter("@CategoryID", SqlDbType.Int, 4), new SqlParameter("@CategoryName", SqlDbType.NVarChar, 250), new SqlParameter("@Title", SqlDbType.NVarChar, 250), new SqlParameter("@Author", SqlDbType.NVarChar, 250), new SqlParameter("@Publisher", SqlDbType.NVarChar, 250), new SqlParameter("@PublishYear", SqlDbType.NVarChar, 250), new SqlParameter("@Language", SqlDbType.NVarChar, 250), new SqlParameter("@Status", SqlDbType.Int, 4), new SqlParameter("@NewRelease", SqlDbType.Int, 4), new SqlParameter("@BookFeature", SqlDbType.Int, 4), new SqlParameter("@Start", SqlDbType.Int, 4), new SqlParameter("@Limit", SqlDbType.Int, 4), new SqlParameter("@EnglishBook", SqlDbType.Int, 4) }; p[0].Value = _BookID; p[1].Value = _CategoryID; p[2].Value = _CategoryName; p[3].Value = _Title; p[4].Value = _Author; p[5].Value = _Publisher; p[6].Value = _PublishYear; p[7].Value = _Language; p[8].Value = _Status; p[9].Value = _NewRelease; p[10].Value = _BookFeature; p[11].Value = _Start; p[12].Value = _Limit; p[13].Value = _EnglishBook; DataTable dt = db.ExcuteSelectReturnDataTable("EnglishBook_Select", CommandType.StoredProcedure, p); if (dt.Rows.Count > 0) { foreach (DataRow dr in dt.Rows) { Model.Book model = new Model.Book(); model.Ind = Convert.ToInt32(dr["Ind"]); model.BookID = Convert.ToInt64(dr["BookID"]); model.Code = dr["Code"].ToString(); model.Title = dr["Title"].ToString(); model.TitleUrl = dr["TitleUrl"].ToString(); model.Author = dr["Author"].ToString(); model.Publisher = dr["Publisher"].ToString(); model.PublishYear = dr["PublishYear"].ToString(); model.Language = dr["Language"].ToString(); model.PageNumber = Convert.ToInt32(dr["PageNumber"]); model.Price = Convert.ToInt32(dr["Price"]); model.PriceText = dr["PriceText"].ToString(); model.Amount = Convert.ToInt32(dr["Amount"]); model.Rating = Convert.ToInt16(dr["Rating"]); model.SmallPicture = dr["SmallPicture"].ToString(); model.BigPicture = dr["BigPicture"].ToString(); model.Intro = dr["Intro"].ToString(); model.Content = dr["Content"].ToString(); model.Status = Convert.ToInt16(dr["Status"]); model.BookFeature = Convert.ToInt16(dr["BookFeature"]); model.NewRelease = Convert.ToInt16(dr["NewRelease"]); model.EnglishBook = Convert.ToInt16(dr["EnglishBook"]); model.Particular = dr["Particular"].ToString(); model.Deleted = Convert.ToInt32(dr["Deleted"]); model.DeleteBy = dr["DeleteBy"].ToString(); model.DeleteTime = dr["DeleteTime"].ToString(); model.CreateBy = dr["CreateBy"].ToString(); model.CreateTime = dr["CreateTime"].ToString(); model.UpdateBy = dr["UpdateBy"].ToString(); model.UpdateTime = dr["UpdateTime"].ToString(); model.TotalRow = Convert.ToInt64(dr["TotalRow"]); // Lay danh sach BookCategory BLL.BookCategory bll_bookcategory = BLL.BookCategory.Instance; List<Model.BookCategory> BookCategoryList = bll_bookcategory.GetList(-1, -1, _BookID, 1, 1, 1000); model.BookCategory = BookCategoryList; lModel.Add(model); } } } catch (Exception ex) { PTSLog.Error(ex.Message); } return lModel; }
private Model.Book getBook() { Model.Book book = new Model.Book(); book.Name = textBox1.Text; book.Id = textBox2.Text; book.Author = textBox3.Text; book.Publisher = textBox4.Text; book.Amount = textBox5.Text; return book; }
public static void InitTestDBContext(ECAEntities @this) { using (SpreadsheetDocument mySpreadsheet = SpreadsheetDocument.Open(@"../../TestData.xlsx", false)) { var sheets = mySpreadsheet.WorkbookPart.Workbook.Sheets; SharedStringTable stringTable = mySpreadsheet.WorkbookPart.SharedStringTablePart.SharedStringTable; //Author Sheet sAuthor = sheets.Descendants<Sheet>().Where(s => s.Name == "Author").FirstOrDefault(); WorksheetPart wsPart = mySpreadsheet.WorkbookPart.GetPartById(sAuthor.Id) as WorksheetPart; SheetData sheetData = wsPart.Worksheet.Elements<SheetData>().First(); @this.Authors = new FakeDbSet<Model.Author>(); foreach (Row r in sheetData.Elements<Row>()) { if (r.RowIndex == 1) continue; ECA.Model.Author author = new Model.Author(); author.AuthorId = GetStringValue(stringTable, r.Elements<Cell>().ElementAt(0), 0); author.AuthorName = GetStringValue(stringTable, r.Elements<Cell>().ElementAt(1), 1); @this.Authors.Add(author); } //Book Sheet sBook = sheets.Descendants<Sheet>().Where(s => s.Name == "Book").FirstOrDefault(); wsPart = mySpreadsheet.WorkbookPart.GetPartById(sBook.Id) as WorksheetPart; sheetData = wsPart.Worksheet.Elements<SheetData>().First(); @this.Books = new FakeDbSet<Model.Book>(); foreach (Row r in sheetData.Elements<Row>()) { if (r.RowIndex == 1) continue; ECA.Model.Book book = new Model.Book(); book.ID = GetStringValue(stringTable, r.Elements<Cell>().ElementAt(0), 0); book.Title = GetStringValue(stringTable, r.Elements<Cell>().ElementAt(1), 1); book.Description = GetStringValue(stringTable, r.Elements<Cell>().ElementAt(2), 2); book.AuthorId = GetStringValue(stringTable, r.Elements<Cell>().ElementAt(3), 3); book.GenreId = GetStringValue(stringTable, r.Elements<Cell>().ElementAt(4), 4); book.CategoryId = GetStringValue(stringTable, r.Elements<Cell>().ElementAt(5), 5); book.ISBN = GetStringValue(stringTable, r.Elements<Cell>().ElementAt(6), 6); @this.Books.Add(book); } //Book Category Sheet sBookCategory = sheets.Descendants<Sheet>().Where(s => s.Name == "BookCategory").FirstOrDefault(); wsPart = mySpreadsheet.WorkbookPart.GetPartById(sBookCategory.Id) as WorksheetPart; sheetData = wsPart.Worksheet.Elements<SheetData>().First(); @this.BookCategories = new FakeDbSet<Model.BookCategory>(); foreach (Row r in sheetData.Elements<Row>()) { if (r.RowIndex == 1) continue; ECA.Model.BookCategory category = new Model.BookCategory(); category.CategoryId = GetStringValue(stringTable, r.Elements<Cell>().ElementAt(0), 0); category.CategoryName = GetStringValue(stringTable, r.Elements<Cell>().ElementAt(1), 1); @this.BookCategories.Add(category); } //Genre Sheet sGenre = sheets.Descendants<Sheet>().Where(s => s.Name == "Genre").FirstOrDefault(); wsPart = mySpreadsheet.WorkbookPart.GetPartById(sGenre.Id) as WorksheetPart; sheetData = wsPart.Worksheet.Elements<SheetData>().First(); @this.Genres = new FakeDbSet<Model.Genre>(); foreach (Row r in sheetData.Elements<Row>()) { if (r.RowIndex == 1) continue; ECA.Model.Genre genre = new Model.Genre(); genre.GenreId = GetStringValue(stringTable, r.Elements<Cell>().ElementAt(0), 0); genre.GenreName = GetStringValue(stringTable, r.Elements<Cell>().ElementAt(1), 1); @this.Genres.Add(genre); } //Shopping Cart Sheet sCart = sheets.Descendants<Sheet>().Where(s => s.Name == "Cart").FirstOrDefault(); wsPart = mySpreadsheet.WorkbookPart.GetPartById(sCart.Id) as WorksheetPart; sheetData = wsPart.Worksheet.Elements<SheetData>().First(); @this.Carts = new FakeDbSet<Model.Cart>(); foreach (Row r in sheetData.Elements<Row>()) { if (r.RowIndex == 1) continue; ECA.Model.Cart cart = new Model.Cart(); cart.UserId = Convert.ToInt32( r.Elements<Cell>().ElementAt(0).CellValue.Text); cart.ItemCode = GetStringValue(stringTable, r.Elements<Cell>().ElementAt(1), 1); cart.Quantity = Convert.ToInt32(r.Elements<Cell>().ElementAt(2).CellValue.Text); @this.Carts.Add(cart); } //Users Sheet sUser = sheets.Descendants<Sheet>().Where(s => s.Name == "User").FirstOrDefault(); wsPart = mySpreadsheet.WorkbookPart.GetPartById(sUser.Id) as WorksheetPart; sheetData = wsPart.Worksheet.Elements<SheetData>().First(); @this.Users = new FakeDbSet<Model.User>(); foreach (Row r in sheetData.Elements<Row>()) { if (r.RowIndex == 1) continue; ECA.Model.User user = new Model.User(); user.UserId = Convert.ToInt32(r.Elements<Cell>().ElementAt(0).CellValue.Text); user.UserName = GetStringValue(stringTable, r.Elements<Cell>().ElementAt(1), 1); @this.Users.Add(user); } //Roles Sheet sRoles = sheets.Descendants<Sheet>().Where(s => s.Name == "Role").FirstOrDefault(); wsPart = mySpreadsheet.WorkbookPart.GetPartById(sRoles.Id) as WorksheetPart; sheetData = wsPart.Worksheet.Elements<SheetData>().First(); @this.webpages_Roles = new FakeDbSet<Model.webpages_Roles>(); foreach (Row r in sheetData.Elements<Row>()) { if (r.RowIndex == 1) continue; ECA.Model.webpages_Roles role = new Model.webpages_Roles(); role.RoleId = Convert.ToInt32(r.Elements<Cell>().ElementAt(0).CellValue.Text); role.RoleName = GetStringValue(stringTable, r.Elements<Cell>().ElementAt(1), 1); @this.webpages_Roles.Add(role); } @this.webpages_Roles.Where(r => r.RoleId == 1).FirstOrDefault().Users = new List<User>() { new User(){ UserId = 1, UserName = "******"}, new User(){ UserId = 2,UserName = "******"} }; @this.webpages_Roles.Where(r => r.RoleId == 2).FirstOrDefault().Users = new List<User>() { new User(){ UserId = 3, UserName = "******"} }; //Membership Sheet sMembership = sheets.Descendants<Sheet>().Where(s => s.Name == "Membership").FirstOrDefault(); wsPart = mySpreadsheet.WorkbookPart.GetPartById(sMembership.Id) as WorksheetPart; sheetData = wsPart.Worksheet.Elements<SheetData>().First(); @this.webpages_Membership = new FakeDbSet<Model.webpages_Membership>(); foreach (Row r in sheetData.Elements<Row>()) { if (r.RowIndex == 1) continue; ECA.Model.webpages_Membership membership = new Model.webpages_Membership(); membership.UserId = Convert.ToInt32(r.Elements<Cell>().ElementAt(0).CellValue.Text); membership.Password = GetStringValue(stringTable, r.Elements<Cell>().ElementAt(6), 6); @this.webpages_Membership.Add(membership); } } }
public void ProcessRequest(HttpContext context) { if (!string.IsNullOrEmpty(context.Request.Form["action"])) { string action = context.Request.Form["action"]; if (action == "change")//更新商品数量 { int pk, bookId, count; if (!int.TryParse(context.Request.Form["pk"], out pk)) { context.Response.Write("no-参数错误!"); return; } if (!int.TryParse(context.Request.Form["count"], out count)) { context.Response.Write("no-参数错误!"); return; } if (!int.TryParse(context.Request.Form["bookId"], out bookId)) { context.Response.Write("no-参数错误!"); return; } BLL.BookManager bookBll = new BookShop.BLL.BookManager(); Model.Book modelBook = bookBll.GetModel(bookId); if (modelBook != null)//看一下该书是否存在 { BLL.CartManager cartBll = new BookShop.BLL.CartManager(); Model.Cart cartModel = cartBll.GetModel(pk); if (cartModel != null)//根据主键查找该购物车中商品项 { cartModel.Count = count; cartBll.Update(cartModel);//完成数量的更新 context.Response.Write("yes"); } else { context.Response.Write("no"); return; } } else { context.Response.Write("no"); } } //删除一条记录 else if (action == "delete") { if (!string.IsNullOrEmpty(context.Request.Form["pk"])) { int pkId = 0; if (!int.TryParse(context.Request.Form["pk"], out pkId)) { context.Response.Write("no"); return; } BLL.CartManager bllCart = new BookShop.BLL.CartManager(); bllCart.Delete(pkId); context.Response.Write("yes"); } } } }
public void getRecordBorrowTime() { string b_id = "9787550264601"; string r_id = "s001"; Model.Viewer v = new Model.Viewer(); v.Id = r_id; Model.Book b = new Model.Book(); b.Id = b_id; DateTime expected = new DateTime(); //期望值 expected = Convert.ToDateTime("2015-12-15"); DateTime actual; SQLDAL.Record target = new SQLDAL.Record(); actual = target.getRecordBorrowTime(b, v); //实际值 Assert.AreEqual(expected, actual); }
public void ReturnBIdErrTest() { string b_id = "9787550264"; string r_id = "s001"; Model.Viewer v = new Model.Viewer(); v.Id = r_id; Model.Book b = new Model.Book(); b.Id = b_id; Model.Manager m = new Model.Manager(); //m.Id = m_id; //Model.Book book = new Model.Book(); //Model.Viewer viewer = new Model.Viewer(); Model.Manager manager = new Model.Manager(); //book.Id = "boo";//书号错误 //viewer.Id = "st"; manager.Id = "manager"; bool expected = false; //期望值 bool actual; SQLDAL.Book target = new SQLDAL.Book(); actual = target.ReturnBook(v, b, manager); //实际值 Assert.AreEqual(expected, actual); }
public void MulReturnTest() { Model.Book book = new Model.Book(); Model.Viewer viewer = new Model.Viewer(); Model.Manager manager = new Model.Manager(); book.Id = "9787513318525"; viewer.Id = "st"; manager.Id = "manager"; bool expected = false; //期望值 bool actual; SQLDAL.Book target = new SQLDAL.Book(); target.ReturnBook(viewer, book, manager); //第一次还 actual = target.ReturnBook(viewer, book, manager); //实际值//第二次还 Assert.AreEqual(expected, actual); }
public void Delete(int id) { Model.Book book = Get(id); _dataContext.Books.Remove(book); _dataContext.SaveChanges(); }
public Boolean Delete(Model.Book book) { return(false); }
public async Task OnGet(int id) { Book = await _dbContext.Books.FindAsync(id); }
public IActionResult Get(int id) { Model.Book book = _bookRepository.Get(id); return(new JsonResult(book)); }
public List<Model.Book> SearchResult(string _Keyword, int _Start, int _Limit) { List<Model.Book> lModel = new List<Model.Book>(); try { SqlParameter[] p = { new SqlParameter("@Keyword", SqlDbType.NVarChar, 250), new SqlParameter("@Start", SqlDbType.Int, 4), new SqlParameter("@Limit", SqlDbType.Int, 4) }; p[0].Value = _Keyword; p[1].Value = _Start; p[2].Value = _Limit; DataTable dt = db.ExcuteSelectReturnDataTable("Book_Search", CommandType.StoredProcedure, p); if (dt.Rows.Count > 0) { foreach (DataRow dr in dt.Rows) { Model.Book model = new Model.Book(); model.Ind = Convert.ToInt32(dr["Ind"]); model.BookID = Convert.ToInt64(dr["BookID"]); model.Code = dr["Code"].ToString(); model.Title = dr["Title"].ToString(); model.TitleUrl = dr["TitleUrl"].ToString(); model.Author = dr["Author"].ToString(); model.Publisher = dr["Publisher"].ToString(); model.PublishYear = dr["PublishYear"].ToString(); model.Language = dr["Language"].ToString(); model.PageNumber = Convert.ToInt32(dr["PageNumber"]); model.Price = Convert.ToInt32(dr["Price"]); model.PriceText = dr["PriceText"].ToString(); model.Amount = Convert.ToInt32(dr["Amount"]); model.Rating = Convert.ToInt16(dr["Rating"]); model.SmallPicture = dr["SmallPicture"].ToString(); model.BigPicture = dr["BigPicture"].ToString(); model.Intro = dr["Intro"].ToString(); model.Content = dr["Content"].ToString(); model.Status = Convert.ToInt16(dr["Status"]); model.BookFeature = Convert.ToInt16(dr["BookFeature"]); model.NewRelease = Convert.ToInt16(dr["NewRelease"]); model.EnglishBook = Convert.ToInt16(dr["EnglishBook"]); model.Particular = dr["Particular"].ToString(); model.Deleted = Convert.ToInt32(dr["Deleted"]); model.DeleteBy = dr["DeleteBy"].ToString(); model.DeleteTime = dr["DeleteTime"].ToString(); model.CreateBy = dr["CreateBy"].ToString(); model.CreateTime = dr["CreateTime"].ToString(); model.UpdateBy = dr["UpdateBy"].ToString(); model.UpdateTime = dr["UpdateTime"].ToString(); model.TotalRow = Convert.ToInt64(dr["TotalRow"]); lModel.Add(model); } } } catch (Exception ex) { PTSLog.Error(ex.Message); } return lModel; }
public IActionResult Insert([FromBody] Model.Book book) { _bookRepository.Insert(book); return(new JsonResult(book)); }
public static void SaveBook(Model.Book book) { }
public IActionResult Update([FromBody] Model.Book book) { _bookRepository.Update(book); return(new JsonResult(book)); }
public static Model.Book initBook() { string b_id = TestHelper.getString(10); ChineseString.RandomChinese str = new ChineseString.RandomChinese(); string book_name = str.GetRandomChinese(5); string author = str.GetRandomChinese(3); string publisher = str.GetRandomChinese(2) + "出版社"; int amout = TestHelper.getRandomNum(20, 50); Model.Book book = new Model.Book(); book.Id = b_id; book.Name = book_name; book.Author = author; book.Publisher = publisher; book.Amount = amout.ToString(); return book; }
public void ReturnVIdErrTest() { Model.Book book = new Model.Book(); Model.Viewer viewer = new Model.Viewer(); Model.Manager manager = new Model.Manager(); book.Id = "book"; viewer.Id = "s00001";//学号错误 manager.Id = "manager"; bool expected = false; //期望值 bool actual; SQLDAL.Book target = new SQLDAL.Book(); actual = target.ReturnBook(viewer, book, manager); //实际值 Assert.AreEqual(expected, actual); }
protected void btnSubmit_Click(object sender, EventArgs e) { string _createBy = ""; if (Utils.GetCookie(PTSKeys.ADMIN_NAME, PTSKeys.CDL_CMS_KEY) != null) { _createBy = Utils.GetCookie(PTSKeys.ADMIN_NAME, PTSKeys.CDL_CMS_KEY); } string[] albumArr = Request.Form.GetValues("hide_book_category"); List<Model.BookCategory> bookCategory = new List<Model.BookCategory>(); if (null != albumArr && albumArr.Length > 0) { for (int i = 0; i < albumArr.Length; i++) { bookCategory.Add(new Model.BookCategory { BookID = this.id, CategoryID = Convert.ToInt32(albumArr[i]), Status = 1, CreateBy = _createBy }); } } Model.Book model = new Model.Book(); if (this.id > 0) { model = bll.GetModel(this.id, -1, "", "", "", "", "", "", -1, -1, -1, 1, 1); } model.Title = txtTitle.Text.Trim(); model.TitleUrl = Utils.GenURL(txtTitle.Text.Trim()); model.Author = txtAuthor.Text.Trim(); model.Publisher = txtPublisher.Text.Trim(); model.PublishYear = txtPublishYear.Text.Trim(); model.Language = txtLanguage.Text.Trim(); model.PageNumber = Convert.ToInt32(txtPageNumber.Text.Trim()); model.Price = Convert.ToInt32(txtPrice.Text.Trim()); model.Rating = Convert.ToInt32(txtRating.Text.Trim()); model.Intro = txtIntro.Value; model.Content = txtContent.Value; model.Particular = txtParticular.Value; model.CreateBy = _createBy; model.UpdateBy = _createBy; model.Status = Convert.ToInt32(rbStatus.SelectedValue); model.NewRelease = Convert.ToInt32(rbNewRelease.SelectedValue); model.BookFeature = Convert.ToInt32(rbBookFeature.SelectedValue); model.EnglishBook = Convert.ToInt16(rbEnglishBook.SelectedValue); model.Deleted = 0; // Convert.ToInt32(rbDelete.SelectedValue); model.Amount = Convert.ToInt32(txtAmount.Text.Trim()); model.SmallPicture = txtSmallImage.Value; model.BigPicture = txtBigImage.Value; int ErrCode = 0; int RowEffects = 0; bll.Update(model, ref ErrCode, ref RowEffects); if (RowEffects > 0) { ProcessBookCategory(bookCategory); JscriptMsg(ErrCode.ToString() , "List.aspx", "Success"); } else { JscriptMsg(ErrCode.ToString(), "", "Error"); } }
public void Update(Model.Book book) { //foreach () { //} }