public void UpdateGener(EditGenerViewModel tempNewsPaper) { var newsGener = new Gener(); Mapper.Map(tempNewsPaper, newsGener); _generRepository.Update(newsGener); }
public void LoadGenerToList() { conn.Open(); string query = "SELECT * FROM Genres ORDER BY Id"; SqlCommand command = new SqlCommand(query, conn); SqlDataReader reader = command.ExecuteReader(); try { while (reader.Read()) { Gener g = new Gener() { Id = (int)reader["Id"], Name = (string)reader["Name"] }; listBox1_Gener.Items.Add(g.Name); } conn.Close(); } catch (Exception ex) { MessageBox.Show(ex.Message); } }
public HttpResponseMessage NewBook([FromBody] AuthBook data) { try { using (var DB = new BookContext()) { //check if duplicate book if (DB.Books.Where(b => b.bname == data.Book_Name).Count() == 0) { Author auth = new Author(); Gener gns = new Gener(); Book bks = new Book(); auth = repo.chkAuthor(data.Author_Name); gns = repo.chkGenere(data.Gener_Name); bks.bname = data.Book_Name; bks.authors_Id = auth.Id; bks.geners_Id = gns.Id; DB.Books.Add(bks); DB.SaveChanges(); List <Book> query = DB.Books.Where(b => b.authors_Id == auth.Id & b.geners_Id == gns.Id & b.bname == bks.bname).ToList(); return(this.Request.CreateResponse(HttpStatusCode.OK, query)); } else { return(this.Request.CreateResponse(HttpStatusCode.Forbidden, "duplicate book")); } } } catch (Exception ex) { return(this.Request.CreateErrorResponse(HttpStatusCode.BadRequest, ex)); } }
public EditGenerViewModel GetGener(int?id) { Gener tempGener = _generRepository.FindById(id); EditGenerViewModel gener = new EditGenerViewModel(); Mapper.Map(tempGener, gener); return(gener); }
public void SetInDelvWells() { Mesh target = new Mesh(@"D:\T2VOC\FineGridRadial\mesh"); // TODO: Initialize to an appropriate value Gener g = new Gener(); foreach (var v in target.Elements) { } }
private void BTGenerAdd_Click(object sender, RoutedEventArgs e) { Gener gener = new Gener { Gener1 = TBGenerAdd.Text }; bs.Gener.Add(gener); Update(); CBGener1.ItemsSource = bs.Gener.Select(x => x.Gener1).ToList(); TBGenerAdd.Clear(); }
private void button1_Click(object sender, EventArgs e) { if (textBox1.Text.Trim().CompareTo("") == 0) { MessageBox.Show("لطفاْ اطلاعات را کامل وارد کنید."); return; } Gener gm = new Gener(); gm.addField("name", textBox1.Text.Trim()); gm.insert(); new geners.showGeners().ShowDialog(); this.Close(); }
public Gener chkGenere(string gname) { using (BookContext db = new BookContext()) { Gener gen = new Gener(); if (db.Geners.Where(gener => gener.gname == gname).Count() == 0) { gen.gname = gname; db.Geners.Add(gen); db.SaveChanges(); gen = db.Geners.Where(gener => gener.gname == gname).SingleOrDefault(); } else { gen = db.Geners.Where(gener => gener.gname == gname).SingleOrDefault(); } return(gen); } }
public void LoadGener() { conn.Open(); string query = "SELECT * FROM Genres order by Id"; SqlCommand command = new SqlCommand(query, conn); SqlDataReader reader = command.ExecuteReader(); while (reader.Read()) { Gener g = new Gener() { Id = (int)reader["Id"], Name = (string)reader["Name"] }; geners.Add(g); comboBox_Gener.Items.Add(g.Name); } conn.Close(); comboBox_Gener.SelectedIndex = 0; }
public void updateBook(AuthBook authBook) { using (BookContext db = new BookContext()) { Author authr = new Author(); Book bk = new Book(); Gener gen = new Gener(); //author authr = db.Authors.Find(authBook.Auhtor_id); authr.name = authBook.Author_Name; //book bk = db.Books.Find(authBook.Book_id); bk.bname = authBook.Book_Name; //genres gen = db.Geners.Find(authBook.Gener_id); gen.gname = authBook.Gener_Name; db.SaveChanges(); } }
private void button1_Click(object sender, EventArgs e) { if (textBox1.Text.Trim().CompareTo("") == 0) { MessageBox.Show("لطفاْ اطلاعات را کامل وارد کنید."); return; } Gener um = new Gener(); um.addField("id", textBox1.Text.Trim()); try { um.delete(); } catch { } new geners.showGeners().ShowDialog(); this.Close(); }
public void CreateGener(CreateGenerViewModel cNPDTO) { Gener tempPaper = Mapper.Map <CreateGenerViewModel, Gener>(cNPDTO); _generRepository.Create(tempPaper); }