Example #1
0
        public string Add(User user, UserInfo ui, List<Role> roles)
        {
            ISqlMapper mapper = MapperHelper.GetMapper();
            UserDao dao = new UserDao(mapper);
            UserInfoDao uidao = new UserInfoDao(mapper);
            User_RoleDao urdao = new User_RoleDao(mapper);

            string id = dao.Add(user);
            if (ui != null)
            {
                ui.ID = id;
                uidao.Add(ui);
            }
            if (roles != null)
            {
                foreach (var role in roles)
                {
                    urdao.Add(new User_Role { UserID = id, RoleID = role.ID });
                }
            }
            return id;
        }
Example #2
0
 public string Add(FullUser form)
 {
     User user = new User
     {
         ID = form.ID,
         Enabled = form.Enabled,
         Password = form.Password,
         Name = form.Name,
         IsDeleted = 0,
     };
     UserInfo ui = new UserInfo
     {
         CnName = form.CnName,
         Address = form.Address,
         Identity = form.Identity,
         Mobile = form.Mobile,
         QQ = form.QQ,
         Remark = form.Remark,
         WX = form.WX,
     };
     return bll.Add(user, ui, form.Roles);
 }
Example #3
0
 public bool Update(User user, UserInfo ui, List<Role> roles)
 {
     ISqlMapper mapper = MapperHelper.GetMapper();
     UserDao dao = new UserDao(mapper);
     UserInfoDao uidao = new UserInfoDao(mapper);
     User_RoleDao urdao = new User_RoleDao(mapper);
     var updateuser = GetUserFormCache();
     dao.Update(new UserUpdateForm
     {
         Entity = new User
         {
             Enabled = user.Enabled,
             LastUpdateTime = DateTime.Now,
             LastUpdator = updateuser?.User.ID,
         },
         UserQueryForm = new UserQueryForm { ID = user.ID }
     });
     if (ui != null)
     {
         if (uidao.Query(new UserInfoQueryForm { ID = user.ID }).FirstOrDefault() == null)
         {
             ui.ID = user.ID;
             uidao.Add(ui);
         }
         else
         {
             uidao.Update(new UserInfoUpdateForm
             {
                 Entity = ui,
                 UserInfoQueryForm = new UserInfoQueryForm { ID = user.ID }
             });
         }
     }
     urdao.Delete(new User_RoleQueryForm { UserID = user.ID });
     if (roles != null)
     {
         foreach (var role in roles)
         {
             urdao.Add(new User_Role { UserID = user.ID, RoleID = role.ID });
         }
     }
     return true;
 }
Example #4
0
 public bool Update(FullUser form)
 {
     User user = new User
     {
         ID = form.ID,
         Enabled = form.Enabled,
         Name = form.Name,
     };
     UserInfo ui = new UserInfo
     {
         CnName = form.CnName,
         Address = form.Address,
         Identity = form.Identity,
         Mobile = form.Mobile,
         QQ = form.QQ,
         Remark = form.Remark,
         WX = form.WX,
     };
     return bll.Update(user, ui, form.Roles);
 }