コード例 #1
0
        /// <summary>
        /// 编辑用户
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public ActionResult Edit(int id = 0)
        {
            var req = YunClient.Instance.Execute(new GetUserRequest {UserId = id}, id > 0 ? null : Token).User;

            if (req == null)
            {
                Error404Message = "当前用户不存在";
                return RedirectToAction("Error404", "Home");
            }

            SetUserLocationData(req.Province, req.City, req.Area);

            var rtm = new UpdateMemberModel
            {
                Avatar = req.Avatar,
                UserId = req.UserId,
                Nick = req.Nick,
                Sex = req.Sex,
                CreateTime = req.CreateTime,
                LastVisit = req.LastVisit,
                Email = req.Email,
                Mobile = req.Mobile,
                Score = req.Score,
                Money = req.Money,
                RealName = req.RealName,
                PrepaidCard = req.PrepaidCard,
                Province = req.Province,
                Address = req.Address,
                Area = req.Area,
                City = req.City,
                Remark = req.Remark,
                IdCard = req.IdCard
            };

            if (!string.IsNullOrEmpty(req.Birthday))
            {
                rtm.Birthday = Convert.ToDateTime(req.Birthday);
            }

            //获取远程的现金余额
            if (!GlobeInfo.WebSetting.RemainingCashQueryUrl.IsEmpty())
            {
                ViewData["cashName"] = GlobeInfo.WebSetting.CashPaymentName;

                //获取远程的金额
                ViewData["cashAmount"] = Utilities.Web.ExtensionMethods.HTTPRequestExtensions.GetHtmlCode(
                    GlobeInfo.WebSetting.RemainingCashQueryUrl + "?nick=" + req.Nick);
            }

            return View(rtm);
        }
コード例 #2
0
        public ActionResult Edit(int id = 0)
        {
            var req = YunClient.Instance.Execute(new GetUserRequest {UserId = id}, id > 0 ? null : Token).User;

            if (req == null)
            {
                Error404Message = "当前用户不存在";
                return RedirectToAction("Error404", "Home");
            }

            SetUserLocationData(req.Province, req.City, req.Area);

            var rtm = new UpdateMemberModel
            {
                Avatar = req.Avatar,
                UserId = req.UserId,
                Nick = req.Nick,
                Sex = req.Sex,
                CreateTime = req.CreateTime,
                LastVisit = req.LastVisit,
                Email = req.Email,
                Mobile = req.Mobile,
                Score = req.Score,
                Money = req.Money,
                RealName = req.RealName,
                PrepaidCard = req.PrepaidCard,
                Province = req.Province,
                Address = req.Address,
                Area = req.Area,
                City = req.City,
                Remark = req.Remark
            };

            if (!string.IsNullOrEmpty(req.Birthday))
            {
                rtm.Birthday = Convert.ToDateTime(req.Birthday);
            }

            return View(rtm);
        }
コード例 #3
0
        public ActionResult Edit(UpdateMemberModel model, string redirectUrl = "")
        {
            var province = string.IsNullOrEmpty(model.Province) ? "" : model.Province.Split('-')[0];
            var city = string.IsNullOrEmpty(model.City) ? "" : model.City.Split('-')[0];
            var area = string.IsNullOrEmpty(model.Area) ? "" : model.Area.Split('-')[0];

            var img = FileManage.UploadOneFile();

            var req = YunClient.Instance.Execute(new ModifyUserInfoRequest
            {
                Avatar = string.IsNullOrEmpty(img) ? model.Avatar : img,
                Email = model.Email,
                IsMale = model.Sex == "男" ? 1 : 0,
                Mobile = model.Mobile,
                Nick = model.Nick,
                RealName = model.RealName,
                Address = model.Address,
                Province = province,
                City = city,
                Area = area,
                Birthday = model.Birthday,
                Remark = model.Remark,
                Phone = model.Mobile
            }, Token);

            if (req.Result > 0)
            {
                TempData["success"] = "保存成功";
                if (!string.IsNullOrEmpty(redirectUrl))
                {
                    return Redirect(redirectUrl);
                }
            }

            SetUserLocationData(province, city, area);

            TempData["error"] = "编辑失败,错误原因:" + req.ErrMsg;
            return View(model);
        }