// POST: odata/Products public IHttpActionResult Post(SBook sbook) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } db.SBooks.Add(sbook); db.SaveChanges(); return(Created(sbook)); }
// DELETE: odata/Products(5) public IHttpActionResult Delete([FromODataUri] int key) { SBook sbook = db.SBooks.Find(key); if (sbook == null) { return(NotFound()); } db.SBooks.Remove(sbook); db.SaveChanges(); return(StatusCode(HttpStatusCode.NoContent)); }
// PUT: odata/Products(5) public IHttpActionResult Put([FromODataUri] int key, Delta <SBook> patch) { Validate(patch.GetEntity()); if (!ModelState.IsValid) { return(BadRequest(ModelState)); } SBook sbook = db.SBooks.Find(key); if (sbook == null) { return(NotFound()); } patch.Put(sbook); try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!ProductExists(key)) { return(NotFound()); } else { throw; } } return(Updated(sbook)); }
private void convButton_Click(object sender, EventArgs e) { if (this.inputTextBox.Text == string.Empty) { MessageBox.Show("入力ファイルを設定してください"); return; } if (this.outputTextBox.Text == string.Empty) { MessageBox.Show("出力ファイルを設定してください"); return; } Cursor keep = Cursor.Current; Cursor.Current = Cursors.WaitCursor; try { // 面倒なのでここでやる SBook book; if (Path.GetExtension(this.inputTextBox.Text).ToLower() == ".db") { book = ImportYaneuraOuBook.ImportYaneuraOu(this.inputTextBox.Text); } else if (Path.GetExtension(this.inputTextBox.Text).ToLower() == ".bin") { book = ImportGikouBook.Import(this.inputTextBox.Text); } else { book = SBook.Load(this.inputTextBox.Text); } if (this.comboBox1.SelectedIndex == (int)BookFormat.YaneuraOu2016) { book.ExportYaneuraOUbook(this.outputTextBox.Text); } else if (this.comboBox1.SelectedIndex == (int)BookFormat.Gikou) { book.ExportGikou(this.outputTextBox.Text); } else if (this.comboBox1.SelectedIndex == (int)BookFormat.SBK) { book.Save(this.outputTextBox.Text); } else { book.ExportApery(this.outputTextBox.Text); } Cursor.Current = keep; MessageBox.Show("完了", "メッセージ", MessageBoxButtons.OK); } catch (Exception ex) { Cursor.Current = keep; MessageBox.Show(ex.Message, "エラー", MessageBoxButtons.OK); } }
//add button click event private void addBookBtn_Click(object sender, RoutedEventArgs e) { if (bookNameBox.Text.Length < 1 || ISBNBox.Text.Length < 1 || quantityBox.Text.Length < 1 || editionYearBox.Text.Length < 1 || authorBox.Text.Length < 2 || nbrPagesBox.Text.Length < 1 || !int.TryParse(ISBNBox.Text, out int x5) || !int.TryParse(nbrPagesBox.Text, out int x6) || !int.TryParse(editionYearBox.Text, out int x7) || !float.TryParse(priceBox.Text, out float x8) || !int.TryParse(quantityBox.Text, out int x9)) { if (bookNameBox.Text.Length < 1) { hint1.Text = "Name is empty or too short"; } else { hint1.Text = ""; } if (authorBox.Text.Length < 2) { hint2.Text = "Author is empty or too short"; } else { hint2.Text = ""; } if (ISBNBox.Text.Length < 1) { hint3.Text = "ISBN is empty or too short"; } else if (!int.TryParse(ISBNBox.Text, out int x)) { hint3.Text = "ISBN should be a number"; } else if (nbrPagesBox.Text.Length < 1) { hint3.Text = "Enter number of pages"; } else if (!int.TryParse(nbrPagesBox.Text, out int x2)) { hint3.Text = "NUMBER of pages should be a NUMBER"; } else { hint3.Text = ""; } if (editionYearBox.Text.Length < 1) { hint4.Text = "Year of edition is empty or too short"; } else if (!int.TryParse(editionYearBox.Text, out int x)) { hint4.Text = "year should be a number"; } else { hint4.Text = ""; } if (priceBox.Text.Length < 1) { hint5.Text = "price is empty or too short"; } else if (!float.TryParse(priceBox.Text, out float x)) { hint5.Text = "price should be a number"; } else if (quantityBox.Text.Length < 1) { hint5.Text = "Enter quantity"; } else if (!int.TryParse(quantityBox.Text, out int x2)) { hint5.Text = "quantity should be a NUMBER"; } else if (int.Parse(quantityBox.Text) <= 1) { hint5.Text = "quantity should be >= 1"; } else { hint3.Text = ""; } } else { //success message confirmSnack.IsActive = true; DispatcherTimerConfirmSnack(); //inserting in the database SBook obj = new SBook(bookNameBox.Text, ISBNBox.Text, int.Parse(editionYearBox.Text), int.Parse(nbrPagesBox.Text), authorBox.Text, audienceBox.Text, copyrightHolderBox.Text, editorBox.Text , genreBox.Text, float.Parse(priceBox.Text), languagebox.Text, illustratorBox.Text, int.Parse(quantityBox.Text), BasicRatingBar.Value, coverContainer.Source, aboutBox.Text); obj.insertSaleBook(); } }