Esempio n. 1
0
        public ActionResult Save(tblT_Reservasi emp)
        {
            try
            {
                // TODO: Add insert logic here

                using (MDKAReservasiEntities db = new MDKAReservasiEntities())
                {
                    if (emp.Reservasi_PK > 0)
                    {
                        var v = db.tblT_Reservasi.Where(x => x.Reservasi_PK == emp.Reservasi_PK).FirstOrDefault();

                        if (v != null)
                        {
                            v.Ruangan_FK       = emp.Ruangan_FK;
                            v.SubjectReservasi = emp.SubjectReservasi;
                            v.TanggalReservasi = emp.TanggalReservasi;
                            v.JamMulai         = emp.JamMulai;
                            v.JamSelesai       = emp.JamSelesai;
                        }
                    }
                    else
                    {
                        db.tblT_Reservasi.Add(emp);
                    }

                    db.SaveChanges();
                    status = true;
                }

                return(new JsonResult {
                    Data = new { status = status }
                });
            }
            catch
            {
                return(View());
            }
        }
Esempio n. 2
0
 public ActionResult DeleteEmployee(int id)
 {
     try
     {
         bool status = false;
         using (MDKAReservasiEntities dc = new MDKAReservasiEntities())
         {
             var v = dc.tblT_Reservasi.Where(a => a.Reservasi_PK == id).FirstOrDefault();
             if (v != null)
             {
                 dc.tblT_Reservasi.Remove(v);
                 dc.SaveChanges();
                 status = true;
             }
         }
         return(new JsonResult {
             Data = new { status = status }
         });
     }
     catch
     {
         return(View());
     }
 }