public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            employ_user employ_user = db.employ_user.Find(id);

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

            var departmentList  = db.departments.ToList();
            var DesignationList = db.Designations.ToList();

            ViewBag.dplist = departmentList;
            ViewBag.dglist = DesignationList;
            employ_user emp = new employ_user()
            {
                departmentId = 1
            };

            return(View(employ_user));
        }
        public ActionResult DeleteConfirmed(int id)
        {
            employ_user employ_user = db.employ_user.Find(id);

            db.employ_user.Remove(employ_user);
            db.SaveChanges();
            TempData["userName"] = employ_user.name;
            TempData["ErrMes"]   = "user successfully";
            TempData["Action"]   = "Delete";
            return(RedirectToAction("Index"));
        }
 public ActionResult Edit([Bind(Include = "id,name,Password,date,phone,email,departmentId,DesignationId")] employ_user employ_user)
 {
     if (ModelState.IsValid)
     {
         db.Entry(employ_user).State = EntityState.Modified;
         db.SaveChanges();
         TempData["userName"] = employ_user.name;
         TempData["ErrMes"]   = "User successfully";
         TempData["Action"]   = "Update";
         return(RedirectToAction("Index"));
     }
     return(View(employ_user));
 }
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            employ_user employ_user = db.employ_user.Find(id);

            if (employ_user == null)
            {
                return(HttpNotFound());
            }
            return(View(employ_user));
        }
        public ActionResult Create([Bind(Include = "id,name,Password,date,phone,email,departmentId,DesignationId")] employ_user employ_user)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    db.employ_user.Add(employ_user);
                    db.SaveChanges();
                    TempData["userName"] = employ_user.name;
                    TempData["Action"]   = "Save";
                    TempData["ErrMes"]   = "user successfully";

                    return(RedirectToAction("Index"));
                }
            }
            catch (Exception e)
            {
                TempData["ErrMes"] = "2" + e.Message;
                return(RedirectToAction("Index"));
            }


            return(View(employ_user));
        }