public string Add(FullUserInfo user) { var mapper = Common.GetMapper(); UserDao userDao = new UserDao(mapper); var repeateUser = userDao.Query(new UserQueryForm { Name = user.Name }).FirstOrDefault(); if (repeateUser != null) { throw new XinLuClubException(402, "用户名已存在"); } var result = userDao.Add(user); if (user.Boards != null) { User_BoardGroupDao ubdao = new User_BoardGroupDao(mapper); user.Boards.ForEach(t => { User_BoardGroup ub = new User_BoardGroup { UserID = result.ID, BoardGroupID = t.ID, }; ubdao.Add(ub); }); } return(result.ID); }
public bool Update(FullUserInfo user) { var mapper = Common.GetMapper(); UserDao userdao = new UserDao(mapper); User_BoardGroupDao ubdao = new User_BoardGroupDao(mapper); ubdao.Delete(new User_BoardGroupQueryForm { UserID = user.ID }); if (user.Boards != null) { user.Boards.ForEach(t => { User_BoardGroup ub = new User_BoardGroup { UserID = user.ID, BoardGroupID = t.ID, }; ubdao.Add(ub); }); } return(userdao.Update(new UserUpdateForm { Entity = new User { WeiXin = user.WeiXin, Enabled = user.Enabled, Gender = user.Gender, IdentityCode = user.IdentityCode, IsAdmin = user.IsAdmin, Mobile = user.Mobile, RealName = user.RealName, }, QueryForm = new UserQueryForm { ID = user.ID } })); }