Esempio n. 1
0
        public void UpdateGener(EditGenerViewModel tempNewsPaper)
        {
            var newsGener = new Gener();

            Mapper.Map(tempNewsPaper, newsGener);
            _generRepository.Update(newsGener);
        }
Esempio n. 2
0
        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); }
        }
Esempio n. 3
0
        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));
            }
        }
Esempio n. 4
0
        public EditGenerViewModel GetGener(int?id)
        {
            Gener tempGener          = _generRepository.FindById(id);
            EditGenerViewModel gener = new EditGenerViewModel();

            Mapper.Map(tempGener, gener);

            return(gener);
        }
Esempio n. 5
0
        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)
            {
            }
        }
Esempio n. 6
0
        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();
        }
Esempio n. 7
0
        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();
        }
Esempio n. 8
0
 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);
     }
 }
Esempio n. 9
0
        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;
        }
Esempio n. 10
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();
            }
        }
Esempio n. 11
0
        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();
        }
Esempio n. 12
0
        public void CreateGener(CreateGenerViewModel cNPDTO)
        {
            Gener tempPaper = Mapper.Map <CreateGenerViewModel, Gener>(cNPDTO);

            _generRepository.Create(tempPaper);
        }
Esempio n. 13
0
    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)
      {



      }


    }