//
 // GET: /Admin/Create
  
 public ActionResult Create()
 {
     RegisteredUser RegisteredUser = new RegisteredUser();
     SystemAdmin SystemAdmin = new SystemAdmin();
     SystemAdmin.RegisteredUser = RegisteredUser;
     return View(SystemAdmin);
 }
        public ActionResult Create(SystemAdmin systemadmin)
        {
            systemadmin.RegisteredUser.IsActivated = "Yes";
            
            if (ModelState.IsValid)
            {
                
                db.SystemAdmins.Add(systemadmin);
                db.SaveChanges();
                return RedirectToAction("Index");
            }

            return View(systemadmin);
        }
 public ActionResult Edit(SystemAdmin systemadmin)
 {
     if (ModelState.IsValid)
     {
         db.Entry(systemadmin).State = EntityState.Modified;
         db.Entry(systemadmin.RegisteredUser).State = EntityState.Modified;
         db.SaveChanges();
         string username = FormsAuthentication.Decrypt(Request.Cookies[FormsAuthentication.FormsCookieName].Value).Name;
         if (!systemadmin.RegisteredUser.UserName.Equals(username))
         {
             FormsAuthentication.SignOut();
             Session.Abandon();
         }
         return RedirectToAction("Index", "Home");
     }
     return View(systemadmin);
 }