public void UpdateUserSelfProfile(one.Service.ViewModels.ViewUserProfile model) { Auth_Users user = new Auth_Users() { UserId = model.UserId, Email = model.Email, PhoneNumber = model.Phone, }; Auth_UserInfor userinfor = new Auth_UserInfor() { UserId = model.UserId, Name = model.NickName, QQ = model.QQ, Mobile = model.Mobile, LastUpdateTime = DateTime.Now, Department = model.Department }; user.Auth_UserInfor = userinfor; DataContext.Auth_Users.Attach(user); DataContext.Entry(user).Property(s => s.Email).IsModified = true; DataContext.Entry(user).Property(s =>s.PhoneNumber).IsModified = true; DataContext.Auth_UserInfor.Attach(userinfor); DataContext.Entry(userinfor).Property(a => a.Department).IsModified = true; DataContext.Entry(userinfor).Property(a => a.Name).IsModified = true; DataContext.Entry(userinfor).Property(a => a.QQ).IsModified = true; DataContext.Entry(userinfor).Property(a => a.Mobile).IsModified = true; DataContext.Entry(userinfor).Property(a => a.LastUpdateTime).IsModified = true; DataContext.Commit(); }
public PartialViewResult ProfileInfo(one.Service.ViewModels.ViewUserProfile model) { model.UserId = IdentityExtensions.GetUserId(User.Identity); if (!ModelState.IsValid) { return(PartialView("PP/_profile", model)); } new one.Service.UserService().UpdateUserSelfProfile(model); AddMessage(Core.Enums.status.Success); //ModelState.AddModelError("Success", "数据修改成功!"); //ModelState.AddModelError("Error", "数据修改成功!"); return(PartialView("PP/_profile", model)); }