public static void Add(string so_dk_tau, int?so_thuyenvien, string khuvuc_gapnan, DateTime?tg_gannan, List <int> sucovetau, List <int> sucovenguoi, string coquanxuly, decimal?thiethai_uoctinh, string vido, string kinhdo, string tau_khac, string nguoi_khac, int?chet, int?mattich)
        {
            using (FDBContext db = new FDBContext())
            {
                var kt_thiethaikhaithac = new KT_THIETHAIKHAITHAC()
                {
                    SO_DK_TAU         = so_dk_tau,
                    SO_THUYENVIEN     = so_thuyenvien,
                    KHUVUC_GAPNAN     = khuvuc_gapnan,
                    TG_GAPNAN         = tg_gannan,
                    COQUAN_XULY       = coquanxuly,
                    THIETHAI_UOCTINH  = thiethai_uoctinh,
                    VIDO              = vido,
                    KINHDO            = kinhdo,
                    TAU_KHAC          = tau_khac,
                    NGUOI_KHAC        = nguoi_khac,
                    SO_NGUOI_CHET     = chet,
                    SO_NGUOI_MAT_TICH = mattich
                };

                //sucovetau
                foreach (var sucovetauID in sucovetau)
                {
                    var sucovetaus = db.DSUCOVETAU.Find(sucovetauID);

                    kt_thiethaikhaithac.SUCOVETAU.Add(sucovetaus);
                }

                //sucovenguoi
                foreach (var sucovenguoiID in sucovenguoi)
                {
                    var sucovenguois = db.DSUCOVENGUOI.Find(sucovenguoiID);

                    kt_thiethaikhaithac.SUCOVENGUOI.Add(sucovenguois);
                }

                db.KT_THIETHAIKHAITHAC.Add(kt_thiethaikhaithac);

                db.SaveChanges();
            }
        }
Beispiel #2
0
        public ActionResult Delete(int?id)
        {
            //if (id == null)
            //{
            //    return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
            //}
            //KT_THIETHAIKHAITHACManager.Delete(id);
            //this.Information(String.Format(Constants.NOTIFY_DELETE_SUCCESS, "bản ghi"));
            //return RedirectToAction("Index");

            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            KT_THIETHAIKHAITHAC kt_thiethai = db.KT_THIETHAIKHAITHAC.Find(id);

            db.KT_THIETHAIKHAITHAC.Remove(kt_thiethai);
            db.SaveChanges();
            this.Information(String.Format(Constants.NOTIFY_DELETE_SUCCESS, "bản ghi"));
            return(RedirectToAction("Index"));
        }