Example #1
0
        public int SaveWithSql(entities.Category category)
        {
            entities.Category hasCategory = FindOne(category.GetId());

            SQLiteCommand command;

            if (hasCategory == null)
            {
                Add(category);
                command = new SQLiteCommand("INSERT INTO category(name, parent_id) VALUES(@name, @parent_id)", db.connection);
            }
            else
            {
                command = new SQLiteCommand("UPDATE category SET name = @name, parent_id = @parent_id WHERE id = @id ", db.connection);
            }

            command.Parameters.AddWithValue("@id", category.GetId());
            command.Parameters.AddWithValue("@name", category.GetName());
            command.Parameters.AddWithValue("@parent_id", category.GetParentId());

            int num = command.ExecuteNonQuery();

            return(num);
        }
Example #2
0
 public List <entities.interfaces.CartElement> FindByCategory(entities.Category category)
 {
     return(products.FindAll(x => x.GetCategoryId() == category.GetId()));
 }
Example #3
0
 public List <entities.Product> FindByCategory(entities.Category category)
 {
     return(products.FindAll(x => x.GetCategoryId() == category.GetId()));
 }