Ejemplo n.º 1
0
        public async Task <ActionResult> InsertData(BukuViewModel bukuViewModel)
        {
            PinjamModel model = new PinjamModel();

            model.IdBuku         = bukuViewModel.Judul;
            model.IdUser         = bukuViewModel.User;
            model.TanggalPinjam  = bukuViewModel.TglPinjam;
            model.TanggalKembali = bukuViewModel.TglKembali;

            WebService ws = new WebService();

            TempData["message"] = await ws.PostLilu(AppSettings.BaseUrlApi + "/Pinjam/InsertData", JsonSerializer.Serialize(model));

            TempData["message"] = JsonSerializer.Deserialize <string>((string)TempData["message"]);
            await Load(bukuViewModel);

            return(View("Index", bukuViewModel));
        }
Ejemplo n.º 2
0
        public IActionResult InsertData([FromBody] PinjamModel model)
        {
            string connectionString = ObonCryptography.AES.Decrypt(AppSettings.AppId, AppSettings.ConnectionString);

            try
            {
                using (IDbConnection conn = new SqlConnection(connectionString))
                {
                    string sQuery = @"insert into transaksi (id_buku, id_user, tanggal_pinjam, tanggal_kembali) values ( '" + model.IdBuku + "', '" + model.IdUser + "', '" + model.TanggalPinjam + "', '" + model.TanggalKembali + "')";
                    conn.Open();
                    var result = conn.Query <PinjamModel>(sQuery);
                    return(Ok("Berhasil Pinjam Buku!"));
                }
            }
            catch (Exception ex)
            {
                _ = ex.ToString();

                return(Ok(null));
            }
        }