Beispiel #1
0
        public async Task <ActionResult> Create([Bind(Include = "MaTruong,MaNganh,idMon1,idMon2,idMon3,Nam,Diem,SoLuongTruyCap")] TruongNganhMonthi truongNganhMonthi)
        {
            if (ModelState.IsValid)
            {
                db.TruongNganhMonthis.Add(truongNganhMonthi);
                await db.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }

            ViewBag.MaNganh  = new SelectList(db.Nganhs, "MaNganh", "Ten", truongNganhMonthi.MaNganh);
            ViewBag.MaTruong = new SelectList(db.Truongs, "MaTruong", "Ten", truongNganhMonthi.MaTruong);
            return(View(truongNganhMonthi));
        }
Beispiel #2
0
        public async Task AddValue(string key, int value)
        {
            var watch = Stopwatch.StartNew();
            SystemInformation info = db.SystemInformations.SingleOrDefault(t => t.Key == key);

            if (info == null)
            {
                info       = new SystemInformation();
                info.Key   = key;
                info.value = value;
                db.SystemInformations.Add(info);
                await db.SaveChangesAsync();
            }
            else
            {
                info.value          += value;
                db.Entry(info).State = System.Data.Entity.EntityState.Modified;
                await db.SaveChangesAsync();
            }
            var elapsedMs = watch.ElapsedMilliseconds;
        }