public ActionResult Edit()
        {
            long id = 0;
            

            
            id = Convert.ToInt32(Request.Cookies["memsid"].Value);
            var kk = (from u in db.Mems where u.memsid.Equals(id) select u).FirstOrDefault();

            var abc = new ViewEditRegi
            {
                fname = kk.fname,
                lname = kk.lname,
                Gender=kk.gender,
                email=kk.email,
                passw=kk.passw,
                countryid = kk.Country.COUNTRYID,
                stateid=kk.state.stateid,
                cityid=kk.citytable.cityid,
                aboutme=kk.aboutme,
                isJobseeker = kk.isJobseeker ,
                jobcategoryid = kk.jobcategoryid ,
                designation = kk.designation 

            };

            ViewBag.countryid = new SelectList(db.Countries, "COUNTRYID", "countryname", kk.countryid);
            ViewBag.stateid = new SelectList(db.states, "stateid", "statename", kk.stateid);
            ViewBag.cityid = new SelectList(db.citytables, "cityid", "cityname", kk.cityid);
            ViewBag.jobcategoryid = new SelectList(db.jobcategories, "jobcategoryid", "category", kk.jobcategoryid);

             return View(abc);
        }
        public ActionResult Edit(ViewEditRegi mm)
        {
            if(ModelState.IsValid)
            {
               // db.Entry(mm).State = EntityState.Modified;
                
                

                try
                {
                    var fname = mm.fname; //mm["fname"];
                    var lname =mm.lname;// mm["lname"];
                    var gender =mm.Gender; //mm["gender"];
                    var email =mm.email; //mm["email"];
                    var passw =mm.passw; //mm["passw"];
                    short countryid =mm.countryid; //Convert.ToInt16(mm["Country"]);
                    short State =mm.stateid; //Convert.ToInt16(mm["State"]);
                    short city = mm.cityid;//Convert.ToInt16(mm["city"]);
                    var aboutme = mm.aboutme;
                    var jobcatgoryid = mm.jobcategoryid;
                    var designation = mm.designation;
                    var isjobseeker = mm.isJobseeker;

                    db.Editmem(Convert.ToInt32(Request.Cookies["memsid"].Value), fname, lname, passw, gender, countryid, State, city, aboutme, isjobseeker, jobcatgoryid, designation);

                    
                }
                catch (DbEntityValidationException ex)
                {


                    // Retrieve the error messages as a list of strings.
                    var errorMessages = ex.EntityValidationErrors
                            .SelectMany(x => x.ValidationErrors)
                            .Select(x => x.ErrorMessage);

                    // Join the list to a single string.
                    var fullErrorMessage = string.Join("; ", errorMessages);

                    // Combine the original exception message with the new one.
                    var exceptionMessage = string.Concat(ex.Message, " The validation errors are: ", fullErrorMessage);

                    // Throw a new DbEntityValidationException with the improved exception message.
                    throw new DbEntityValidationException(exceptionMessage, ex.EntityValidationErrors);
                }
                return RedirectToAction("index");
            }
            ViewBag.countryid = new SelectList(db.Countries, "COUNTRYID", "countryname",mm.countryid);
            ViewBag.stateid = new SelectList(db.states, "stateid", "statename",mm.stateid);
            ViewBag.cityid = new SelectList(db.citytables, "cityid", "cityname",mm.cityid);
            ViewBag.jobcategoryid = new SelectList(db.jobcategories, "jobcategoryid", "category", mm.jobcategoryid);

            return View(mm);
        }