Example #1
0
        public Form1()
        {
            InitializeComponent();
            client.BaseAddress = new Uri("http://55a51802.ngrok.io/api/");
            client.DefaultRequestHeaders.Accept.Clear();
            client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));

            brg             = new Barang();
            psn             = new Pesanan();
            lPesanan        = new ListPesanan();
            lDetilTransaksi = new List <DetilTransaksi>();
            gsr             = new Grosir();

            // panel awal yang ditampilkan
            panelLogin.Visible = true;
            panelMain.Visible  = false;

            panelMobile.Visible        = true;
            panelLayanan.Visible       = false;
            panelCart.Visible          = false;
            panelSearchAdvance.Visible = false;
            panelUser.Visible          = false;

            tbMinHarga.Text = "0";
            tbMaxHarga.Text = "0";
            cbTahun.Text    = "None";
            cbTipe.Text     = "None";
            cbUrutkan.Text  = "Termurah";
        }
Example #2
0
 public IActionResult UpdateGrosir(int arg, [FromBody] Grosir item)
 {
     if (repo.updateGrosir(arg, item) > 0)
     {
         return(Ok());
     }
     else
     {
         return(NoContent());
     }
 }
Example #3
0
        public IActionResult CreateTokenGrosir([FromBody] Grosir login)
        {
            IActionResult response = Unauthorized();
            var           user     = AuthenticateGrosir(login);

            if (user != null)
            {
                var tokenString = BuildToken(user);
                response = Ok(new { token = tokenString });
            }

            return(response);
        }
Example #4
0
        public IActionResult GetGrosir(string arg1, string arg2)
        {
            Grosir obj = repo.GetGrosir(arg1, arg2);

            if (obj != null)
            {
                return(Ok(obj));
            }
            else
            {
                return(NotFound("Aduh ga ada"));
            }
        }
Example #5
0
        //Autentikasi grosir
        private UserModel AuthenticateGrosir(Grosir login)
        {
            UserModel user = null;
            RepoUser  repo = new RepoUser();

            try
            {
                Grosir temp = repo.GetGrosir(login.Email, login.Password);
                user = new UserModel {
                    Name = temp.NamaGrosir, Time = DateTime.Now
                };
                return(user);
            }
            catch (Exception)
            {
                return(user);
            }
        }
Example #6
0
        private async void btnLogin_Click(object sender, EventArgs e) //login
        {
            try
            {
                Grosir user = new Grosir {
                    Email = tbLoginEmail.Text, Password = tbLoginPassword.Text
                };
                HttpResponseMessage response = await client.PostAsJsonAsync("Token/Grosir", user);

                response.EnsureSuccessStatusCode();
                tkn = response.Content.ReadAsAsync <Token>().Result;
                MessageBox.Show("Login sukses!");

                client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", tkn.token);
                response = client.GetAsync("Barang/GetAll").Result;
                var brang = response.Content.ReadAsAsync <List <Barang> >().Result;
                if (brang != null)
                {
                    dataGridView1.DataSource = brang;
                }
                else
                {
                    MessageBox.Show("Maaf, item tidak ada."); //Respon kalo ternyata objek yg dikirim itu null
                }
                client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", tkn.token);
                response = client.GetAsync("User/GetGrosir/" + user.Email + "/" + user.Password).Result;
                gsr      = response.Content.ReadAsAsync <Grosir>().Result;



                panelMain.Visible  = true;
                panelLogin.Visible = false;

                panelMobile.Visible        = true;
                panelLayanan.Visible       = false;
                panelCart.Visible          = false;
                panelSearchAdvance.Visible = false;
                panelUser.Visible          = false;
            }
            catch (Exception)
            {
                MessageBox.Show("Login gagal.\nUsername atau password salah.");
            }
        }
Example #7
0
        public int updateGrosir(int id, Grosir item)
        {
            string sql = "UPDATE grosir SET NamaGrosir = '" + item.NamaGrosir + "', Alamat = '" + item.Alamat + "', NamaPemilik = '" + item.NamaPemilik + "', Email = '" + item.Email + "', Password = '******', NoTelp = '" + item.NoTelp + "' WHERE ID = '" + id + "'";

            return(cnn.Execute(sql));
        }