Exemplo n.º 1
0
        public IActionResult Information(Models.InformationUpdateRequestModel requestModel)
        {
            requestModel.AccountId = HttpContext.Session.GetInt32("AccountId").GetValueOrDefault(0);

            if (string.IsNullOrEmpty(requestModel.InformationValue))
            {
                return(APIReturnMethod.ReturnFailed("请输入待修改项的值!"));
            }
            var repository  = _unitOfWork.GetRepository <m_Account>();
            var accountData = repository.Query().Where(q => q.AccountId == requestModel.AccountId).FirstOrDefault();

            switch (requestModel.InformationType)
            {
            case 3:
                accountData.Tags = requestModel.InformationValue;
                break;

            case 4:
                accountData.AddressInfo = requestModel.InformationValue;
                break;

            case 5:
                accountData.Sex = requestModel.InformationValue;
                break;

            case 1:
                accountData.NickName = requestModel.InformationValue;
                break;

            case 2:
                accountData.HeadUrl = requestModel.InformationValue;
                break;
            }
            repository.Update(accountData);
            var resultCount = _unitOfWork.SaveChanges();

            return(resultCount > 0 ? APIReturnMethod.ReturnSuccess() : APIReturnMethod.ReturnFailed());
        }
Exemplo n.º 2
0
        public IActionResult Information(Models.InformationUpdateRequestModel requestModel)
        {
            requestModel.AccountId = HttpContext.Session.GetInt32("AccountId").GetValueOrDefault(0);

            string requestData = JsonConvert.SerializeObject(requestModel);
            var    apiResult   = HttpCore.HttpPut($"/api/Account/Information", requestData);

            if (apiResult.Code == 0)
            {
                var accountLoginData = JsonConvert.DeserializeObject <Models.AccountDataModel>(HttpContext.Session.GetString("AccountLoginData"));
                switch (requestModel.InformationType)
                {
                case 3:
                    accountLoginData.Tags = requestModel.InformationValue;
                    break;

                case 4:
                    accountLoginData.AddressInfo = requestModel.InformationValue;
                    break;

                case 5:
                    accountLoginData.Sex = requestModel.InformationValue;
                    break;

                case 1:
                    accountLoginData.NickName = requestModel.InformationValue;
                    break;

                case 2:
                    accountLoginData.HeadUrl = requestModel.InformationValue;
                    break;
                }
                HttpContext.Session.SetString("AccountLoginData", JsonConvert.SerializeObject(accountLoginData));
            }
            return(Json(apiResult));
        }