예제 #1
0
        public ActionResult EditUser(string id)
        {
            long usr_id;
            if (long.TryParse(id, out usr_id))
            {
                UserInfo usr = _uow.UserInfoService.Get(o => o.Id == usr_id);
                if (usr != null)
                {
                    CustomerEditModel cem = new CustomerEditModel();
                    cem.Id = usr.Id;
                    cem.UserName = usr.UserName;
                    cem.TrueName = usr.TrueName;
                    cem.Email = usr.Email;
                    cem.IdentityCardNo = usr.IdentityCardNo;
                    cem.Tel = usr.Tel;
                    cem.Phone = cem.Phone;

                    return View(cem);
                }
            }

            return View();
        }
예제 #2
0
 public ActionResult EditUser(CustomerEditModel usr)
 {
     if (ModelState.IsValid)
     {
         if (usr.Id != 0)
         {
             UserInfo old_usr = _uow.UserInfoService.Get(o => o.Id == usr.Id);
             if (old_usr != null && old_usr.Id == usr.Id && !string.IsNullOrWhiteSpace(usr.UserName))
             {
                 old_usr.UserName = usr.UserName;
                 old_usr.Email = usr.Email;
                 old_usr.TrueName = usr.TrueName;
                 old_usr.IdentityCardNo = usr.IdentityCardNo;
                 old_usr.Tel = usr.Tel;
                 old_usr.Phone = usr.Phone;
                 old_usr.UpdateTime = DateTime.Now;
                 _uow.Commit();
                 return RedirectToAction("Users"); ;
             }
         }
     }
     ModelState.AddModelError("", "Error Editing User");
     return View(usr);
 }