Exemplo n.º 1
0
        public void AddPanitiaToStaff(Panitia newPanitia)
        {
            string sqlQuery = @"INSERT INTO Panitia(StaffId, Acara, Divisi) 
                                VALUES(@StaffId, @Acara, @Divisi)";

            using (var connection = new SqlConnection(_connectionHelper.GetConnectionString()))
            {
                connection.Open();
                connection.Execute(sql: sqlQuery, param: newPanitia);
            }
        }
Exemplo n.º 2
0
        public IActionResult TambahPanitia(RincianStaffModel model)
        {
            // Cek valid
            if (!ModelState.IsValid)
            {
                TempData["Pesan"] = "Gagal menambah panitia, Data tidak valid";
                return(RedirectToAction(nameof(RincianStaff), new { id = model.Id }));
            }
            else
            {
                var panitiaBaru = new Panitia()
                {
                    StaffId = model.Id,
                    Acara   = model.Panitia.Acara,
                    Divisi  = model.Panitia.Divisi
                };
                _staffServices.AddPanitiaToStaff(panitiaBaru);

                TempData["Pesan"] = "Berhasil menambahkan panitia";
                return(RedirectToAction(nameof(RincianStaff), new { id = model.Id }));
            }
        }