fireBase–part 1

Product win

 

using System;

using System.Collections.Generic;

using System.ComponentModel;

using System.Data;

using System.Drawing;

using System.Linq;

using System.Text;

using System.Threading.Tasks;

using System.Windows.Forms;

 

using FireSharp.Config;

using FireSharp.Interfaces;

using FireSharp.Response;

using Firebase.Database;

 

 

namespace CoffeShop

{

    public partial class productWin : Form

    {

        dbEntities db = new dbEntities();

 

        IFirebaseConfig config = new FirebaseConfig

        {

            AuthSecret = "Your secret",

            BasePath = "your path/"

        };

 

        IFirebaseClient client;

 

        public productWin()

        {

            InitializeComponent();

        }

 

        private void button6_Click(object sender, EventArgs e)

        {

 

            openFileDialog1.Filter = "Image files(*.jpg, *.png,*.gif)|*.jpg; *.png; *.gif";

            openFileDialog1.FileName = "";

 

            DialogResult result =  openFileDialog1.ShowDialog();

           

            if (result == DialogResult.OK)

            {

                textBox7.Text = openFileDialog1.FileName;

 

                pictureBox4.Load(textBox7.Text);

            }

 

        }

 

        private void productWin_Load(object sender, EventArgs e)

        {

            client = new FireSharp.FirebaseClient(config);

        }

    }

}

private async void button1_Click(object sender, EventArgs e)

        {

            productTBL p1 = new productTBL();

            p1.name = textBox1.Text;

            p1.price = Convert.ToInt32(maskedTextBox1.Text);

            categoryTBL c1 = (categoryTBL)comboBox2.SelectedItem;

            p1.catID = c1.Id;

            p1.imgUrl = "";

            p1.description = "";

            p1.fileName = "";

 

            db.productTBL.Add(p1);

            db.SaveChanges();

 

            productView p2 = (from s in db.productView where s.Id == p1.Id select s).FirstOrDefault();

            SetResponse respose = await client.SetTaskAsync("products/" + p2.Id, p2);

            productView result = respose.ResultAs<productView>();

            MessageBox.Show("OK");

        }

    }