Example #1
0
        public ActionResult SaveBasicInfo(Models.BasicInfoDTO infoDTO)
        {
            AjaxResult result = new AjaxResult();

            if (ModelState.IsValid)
            {
                TransactionManager.Excute(delegate {
                    IBasicInfoService basicService = ContainerManager.Resolve <IBasicInfoService>();
                    UserInfo logUser            = UserContext.LoginUser;
                    HxBlogs.Model.UserInfo user = MapperManager.Map <UserInfo>(logUser);
                    BasicInfo basicInfo         = MapperManager.Map <BasicInfo>(infoDTO);
                    basicInfo.Id         = user.BasicId;
                    user.BasicInfo       = basicInfo;
                    user.NickName        = infoDTO.NickName;
                    List <string> fields = new List <string>();
                    fields.AddRange(new string[] { "RealName", "QQ", "WeChat", "Mobile", "Birthday", "Address", "Description" });
                    if (string.IsNullOrEmpty(logUser.BasicInfo.Gender))
                    {
                        fields.Add("Gender");
                    }
                    _userService.UpdateEntityFields(user, "NickName");
                    basicService.UpdateEntityFields(basicInfo, fields);
                    UserContext.UpdateUser(user);
                });
            }
            else
            {
                result = GetErrorResult();
            }
            return(Json(result, JsonRequestBehavior.AllowGet));
        }
Example #2
0
 public BasicInfoController(IBasicInfoService service, IMapper mapper)
 {
     _service = service;
     _mapper  = mapper;
 }