Ejemplo n.º 1
0
        public async Task <ActionResult> ChangeInfo(EditUserViewModel model)
        {
            if (ModelState.IsValid)
            {
                model.Id = User.Identity.GetUserId();
                var u = db.AspNetUsers.FirstOrDefault(c => c.Id == model.Id);
                u.FullName        = model.FullName;
                u.PhoneNumber     = model.PhoneNumber;
                u.MaKTV           = model.MaKTV;
                u.ChucVu          = model.ChucVu;
                u.MaDonVi         = model.MaDonVi;
                u.Email           = model.Email;
                db.Entry(u).State = EntityState.Modified;
                await db.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }
            ViewBag.Donvi = new SelectList(db.TD_DVKT.ToList(), "MA", "TEN");
            return(View(model));
        }
Ejemplo n.º 2
0
        public async Task <ActionResult> Edit([Bind(Include = "MA,TEN")] TD_LHKT l)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    db.Entry(l).State = EntityState.Modified;
                    await db.SaveChangesAsync();

                    TempData["Msg"] = "Đã sửa";

                    return(RedirectToAction("Index"));
                }
                catch (Exception)
                {
                    TempData["Msg"] = "Có lỗi";
                }
            }
            return(PartialView(l));
        }
Ejemplo n.º 3
0
        public async Task <ActionResult> Edit(TD_DVKT d)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    db.Entry(d).State = EntityState.Modified;
                    await db.SaveChangesAsync();

                    TempData["Msg"] = "Đã sửa";
                }
                catch (Exception)
                {
                    TempData["Msg"] = "Có lỗi";
                }

                return(RedirectToAction("Index"));
            }
            return(PartialView(d));
        }
Ejemplo n.º 4
0
        public async Task <ActionResult> Edit(CUOC_KT c)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    c.ID              = int.Parse(Session["EditId"].ToString());
                    c.MA_CUOC         = Session["EditMa"].ToString();
                    db.Entry(c).State = EntityState.Modified;

                    await db.SaveChangesAsync();

                    TempData["Msg"] = "Đã sửa";
                }
                catch (Exception)
                {
                    TempData["Msg"] = "Có lỗi";
                }

                return(RedirectToAction("Index"));
            }
            return(PartialView(c));
        }