Ejemplo n.º 1
0
        public ActionResult Edit(EditUserModel user)
        {
            //  var errors = ModelState
              //.Where(x => x.Value.Errors.Count > 0)
              //.Select(x => new { x.Key, x.Value.Errors })
              //.ToArray();
            if (ModelState.IsValid)
            {
                var userToUpdatebrands = db.User_Info.SingleOrDefault(u => u.UidNo == user.Uidno);
                if (userToUpdatebrands != null)
                {
                    userToUpdatebrands.First_name = user.First_name;

                    userToUpdatebrands.Last_name = user.Last_name;
                    userToUpdatebrands.E_mail_id = user.Email_id;
                    userToUpdatebrands.Mobile_number = user.Mobile_number;
                    userToUpdatebrands.Address_Communication = user.Address_Communication;
                    userToUpdatebrands.DOB = user.DOB;
                    userToUpdatebrands.Gender = user.Gender;
                    userToUpdatebrands.Usr_type = user.user_type;
                    db.SaveChanges();
                }
                TempData["Usr_Message"] = ConfigurationManager.AppSettings["EDT_SUC"];
                return RedirectToAction("Index");

            }
            return View(user);
        }
Ejemplo n.º 2
0
        public ActionResult Edit(int id = 0)
        {
            var model = from p in db.User_Info

                        select new EditUserModel
                        {
                            First_name = p.First_name,
                            Last_name = p.Last_name,
                            Address_Communication = p.Address_Communication,
                            Email_id = p.E_mail_id,
                            Mobile_number = p.Mobile_number,
                            Uidno = p.UidNo,
                            user_type = p.Usr_type,
                            DOB=p.DOB,
                            Gender=p.Gender

                        };
            EditUserModel editprddetails = null;
            foreach (var m in model)
            {
                editprddetails = new EditUserModel();
                editprddetails.Uidno = m.Uidno;
                editprddetails.First_name = m.First_name;
                editprddetails.Last_name = m.Last_name;
                editprddetails.Address_Communication = m.Address_Communication;
                editprddetails.Email_id = m.Email_id;
                editprddetails.Mobile_number = m.Mobile_number;
                   editprddetails.DOB = m.DOB;
                   editprddetails.Gender = m.Gender;
                   editprddetails.user_type = m.user_type;
            }

            var list = new SelectList(new[] { new { ID = "M", Name = "Male" }, new { ID = "F", Name = "FeMale" }, new { ID = "O", Name = "Others" } }, "ID", "Name", 1);
            ViewBag.Genders = list;

            return View(editprddetails);
        }