public ActionResult user_detail(int id, Gabungan gabungan)
        {
            var user = db.pembeli.FirstOrDefault(u => u.id_pembeli == id);

            user.nm_pembeli    = gabungan.tblPembeli.nm_pembeli;
            user.email_pembeli = gabungan.tblPembeli.email_pembeli;
            user.hp_pembeli    = gabungan.tblPembeli.hp_pembeli;
            user.password      = gabungan.tblPembeli.password;
            db.SaveChanges();
            decimal UnformatRpTotalTf = ConvertCurrency.ToAngka(gabungan.rp_total_transfer);
            decimal TotalTf           = gabungan.tblDetailTiket.total_transfer;

            if (UnformatRpTotalTf == TotalTf)
            {
                var userDetail = db.detil_pesan_tiket.FirstOrDefault(u => u.id_pembeli == id);
                userDetail.total_transfer = 0;
                // it's means, number 1 has been paid, so 0 is otherwise
                userDetail.status = 0;
            }
            else
            {
                var userDetail = db.detil_pesan_tiket.FirstOrDefault(u => u.id_pembeli == id);
                userDetail.total_transfer = UnformatRpTotalTf;
                // it's means, number 1 has been paid, so 0 is otherwise
                userDetail.status = 1;
            }
            db.SaveChanges();
            return(RedirectToAction("semua_pembeli", "Admin"));
        }
Exemple #2
0
        public ActionResult daftar(Gabungan gabungan)
        {
            if (gabungan.tblPembeli.password != gabungan.password_conf)
            {
                ViewBag.passTidakSama = "has-error";
                ViewBag.errorMessage  = "Password Konfirmasi Tidak Sama."; return(View());
            }
            string hashPass = PBKDF2Encription.HashPassword(gabungan.tblPembeli.password);

            // table Pembeli
            var dbPembeli = new pembeli
            {
                nm_pembeli    = gabungan.tblPembeli.nm_pembeli,
                email_pembeli = gabungan.tblPembeli.email_pembeli,
                password      = hashPass,
                hp_pembeli    = gabungan.tblPembeli.hp_pembeli,
                gd_pembeli    = gabungan.tblPembeli.gd_pembeli
            };

            db.pembelis.Add(dbPembeli); db.SaveChanges();
            //table tgl Order
            tgl_pesan tgl_table  = new tgl_pesan(); tgl_table.tgl_order = DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss");
            var       dbTglPesan = new tgl_pesan
            {
                nm_pembeli = gabungan.tblPembeli.nm_pembeli,
                tgl_order  = tgl_table.tgl_order
            };

            db.tgl_pesan.Add(dbTglPesan); db.SaveChanges();
            // table Detail Pembeli
            var dbPembeliDetail = new detil_pesan_tiket
            {
                nm_pembeli        = gabungan.tblPembeli.nm_pembeli,
                harga_tiket       = ConvertCurrency.ToAngka(gabungan.rp_harga_tiket),
                total_transfer    = gabungan.tblDetailTiket.total_transfer,
                pilihan_bank      = gabungan.tblDetailTiket.pilihan_bank,
                bandara_berangkat = gabungan.tblDetailTiket.bandara_berangkat,
                bandara_tujuan    = gabungan.tblDetailTiket.bandara_tujuan,
                status            = gabungan.tblDetailTiket.status
            };

            db.detil_pesan_tiket.Add(dbPembeliDetail); db.SaveChanges();
            // table Validasi Pembeli
            var dbValidasi = new pembeli_validasi
            {
                nm_pembeli             = gabungan.tblPembeli.nm_pembeli,
                email_pembeli          = gabungan.tblPembeli.email_pembeli,
                hp_pembeli             = gabungan.tblPembeli.hp_pembeli,
                uang_transfer_validasi = null,
                pilihan_bank           = null
            };

            db.pembeli_validasi.Add(dbValidasi); db.SaveChanges();
            return(RedirectToAction("login_user", "Home"));
        }