Exemplo n.º 1
0
        public async Task <ActionResult> EditRealId(ReadIdEditViewModel model)
        {
            if (!this.ModelState.IsValid)
            {
                return(View(model));
            }

            //处理用户在末尾添加了“族”字。
            if (model.Ethnicity.EndsWith("族"))
            {
                model.Ethnicity.Remove(model.Ethnicity.Length - 1);
            }
            if (string.IsNullOrWhiteSpace(model.Ethnicity))
            {
                this.ModelState.AddModelError(nameof(model.Ethnicity), "必须填写民族名称。民族名称末尾不用添加“族”字。");
                return(View(model));
            }

            model.Issuer  = model.Issuer.Trim().Replace(" ", string.Empty);
            model.Address = model.Address.Trim().Replace(" ", string.Empty);

            var user = this.CurrentUser();

            try
            {
                await this.personManager.UpdateRealIdAsync(user, model.Surname, model.GivenName, model.Ethnicity, model.Address, model.Issuer, model.IssueDate.Value, model.ExpiresAt);
            }
            catch (Exception ex)
            {
                this.ModelState.AddModelError("", ex.Message);
                return(View(model));
            }

            return(RedirectToAction("IDCardFile", "Account"));
        }
Exemplo n.º 2
0
        public ActionResult EditRealId()
        {
            var person = this.CurrentUser();
            var model  = new ReadIdEditViewModel()
            {
                Surname   = person.Surname,
                GivenName = person.GivenName,
                Ethnicity = person.Ethnicity,
                Address   = person.Address,
                Issuer    = person.Issuer,
                IssueDate = person.IssueDate,
                ExpiresAt = person.ExpiresAt,
            };

            return(View(model));
        }