コード例 #1
0
        public List <CarteEntity> CitesteCartile(string cautare = null)
        {
            SQLiteCommand command = new SQLiteCommand(_connection);

            string query = "Select * from Carti";

            if (cautare != null)
            {
                query += $" Where NumeleCartii Like \"%{cautare}%\" OR NumeAutor Like \"%{cautare}%\"";
            }
            command.CommandText = query;

            SQLiteDataReader reader = command.ExecuteReader();

            List <CarteEntity> listaCarti = new List <CarteEntity>();

            while (reader.Read())
            {
                CarteEntity carte = new CarteEntity();
                carte.Id             = reader.GetInt32(0);
                carte.NumeleCartii   = reader.GetString(1);
                carte.NumeAutor      = reader.GetString(2);
                carte.Editura        = reader.GetString(3);
                carte.DataPublicarii = DateTime.Parse(reader.GetString(4));
                carte.NumarPagini    = reader.GetInt32(5);

                listaCarti.Add(carte);
            }
            return(listaCarti);
        }
コード例 #2
0
        public void AdaugaCarte(CarteEntity carte)
        {
            SQLiteCommand command = new SQLiteCommand(_connection);

            command.CommandText = $"INSERT INTO Carti (NumeleCartii, NumeAutor, Editura, DataPublicarii, NumarPagini) VALUES ('{carte.NumeleCartii}', '{carte.NumeAutor}','{carte.Editura}', '{carte.DataPublicarii}','{carte.NumarPagini}')";
            command.ExecuteNonQuery();
        }
コード例 #3
0
        public void Update(int id, CarteEntity entity)
        {
            SQLiteCommand command = new SQLiteCommand(_connection);

            command.CommandText = $"Update Carti Set NumeAutor=\"{entity.NumeAutor}\"" +
                                  $",Editura=\"{entity.Editura}\",DataPublicarii=\"{entity.DataPublicarii}\"," +
                                  $"NumarPagini=\"{entity.NumarPagini}\" where id={id}";

            command.ExecuteNonQuery();
        }
コード例 #4
0
        private CarteEntity Map(Carte model)
        {
            CarteEntity entity = new CarteEntity
            {
                DataPublicarii = model.DataPublicarii,
                Editura        = model.Editura,
                NumarPagini    = model.NumarPagini,
                NumeAutor      = model.NumeAutor,
                NumeleCartii   = model.NumeleCartii
            };

            return(entity);
        }
コード例 #5
0
        private Carte Map(CarteEntity entity)
        {
            Carte model = new Carte
            {
                Id             = entity.Id,
                DataPublicarii = entity.DataPublicarii,
                Editura        = entity.Editura,
                NumarPagini    = entity.NumarPagini,
                NumeAutor      = entity.NumeAutor,
                NumeleCartii   = entity.NumeleCartii
            };

            return(model);
        }
コード例 #6
0
        public List <CarteEntity> CitesteCartile()
        {
            SQLiteCommand command = new SQLiteCommand(_connection);

            command.CommandText = "Select * from Carti";
            SQLiteDataReader reader = command.ExecuteReader();

            List <CarteEntity> listaCarti = new List <CarteEntity>();

            while (reader.Read())
            {
                CarteEntity carte = new CarteEntity();
                carte.Id             = reader.GetInt32(0);
                carte.NumeleCartii   = reader.GetString(1);
                carte.NumeAutor      = reader.GetString(2);
                carte.Editura        = reader.GetString(3);
                carte.DataPublicarii = DateTime.Parse(reader.GetString(4));
                carte.NumarPagini    = reader.GetInt32(5);

                listaCarti.Add(carte);
            }
            return(listaCarti);
        }