public async Task <ActionResult> Edit(PegawaiViewModels vmPegawai)
        {
            if (ModelState.IsValid)
            {
                var pegawai = await db.PEGAWAIs.Include("ROLE").Where(x => x.PEGAWAI_ID == vmPegawai.PEGAWAI_ID).SingleOrDefaultAsync();

                var role = await db.ROLEs.FindAsync(Convert.ToInt32(vmPegawai.ROLE_ID));

                pegawai.NAMA          = vmPegawai.NAMA;
                pegawai.ALAMAT        = vmPegawai.ALAMAT;
                pegawai.NO_TELP       = pegawai.NO_TELP;
                pegawai.JENIS_KELAMIN = vmPegawai.JENIS_KELAMIN;
                pegawai.STATUS        = vmPegawai.STATUS;
                pegawai.EMAIL         = vmPegawai.EMAIL;
                pegawai.PASSWORD      = vmPegawai.PASSWORD;

                if (role != null)
                {
                    pegawai.ROLE            = role;
                    db.Entry(pegawai).State = EntityState.Modified;
                    await db.SaveChangesAsync();

                    return(RedirectToAction("Index"));
                }
            }
            return(View(vmPegawai));
        }
        public async Task <ActionResult> Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }

            PEGAWAI pegawai = await db.PEGAWAIs.FindAsync(id);

            var role = await db.ROLEs.Where(x => x.ROLE_ID != 1).Select(i => new SelectListItem()
            {
                Text     = i.NAMA,
                Value    = i.ROLE_ID.ToString(),
                Selected = false
            }).ToArrayAsync();


            if (pegawai == null)
            {
                return(HttpNotFound());
            }

            foreach (var item in role)
            {
                if (item.Value == pegawai.ROLE.ROLE_ID.ToString())
                {
                    item.Selected = true;
                    break;
                }
            }

            ViewBag.Role = role;
            var vmRuangan = new PegawaiViewModels(pegawai);

            return(View(vmRuangan));
        }