示例#1
0
        //GET; /Manage/ChangeNumber
        public ActionResult ChangeNumber()
        {
            ApplicationDbContext ctx = ApplicationDbContext.Create();
            var user = ctx.Users.Find(User.Identity.GetUserId());
            ChangePhoneViewModel model = new ChangePhoneViewModel
            {
                PhoneNumber = user.PhoneNumber,
            };

            return(View(model));
        }
示例#2
0
        public ActionResult ChangePhone(GetChangePhoneRequest request)
        {
            var model = new ChangePhoneViewModel(
                request.OldPhone,
                request.NewPhone,
                request.IsPhoneNotChanged,
                request.IsPhoneExists,
                request.IsInvalidCredentials);

            return(View("~/OAuth/Views/ChangePhone.cshtml", model));
        }
 public async Task <ActionResult> ChangePhone(ChangePhoneViewModel model)
 {
     if (!ModelState.IsValid)
     {
         return(View(model));
     }
     using (ApplicationDbContext db = new ApplicationDbContext())
     {
         var userId = User.Identity.GetUserId();
         var user   = db.Users.FirstOrDefault(x => x.Id == userId);
         user.Phone           = model.Number;
         db.Entry(user).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index", new { Message = ManageMessageId.ChangePhoneSuccess }));
     }
 }
示例#4
0
        public ActionResult ChangeNumber(ChangePhoneViewModel model)
        {
            ApplicationDbContext ctx = ApplicationDbContext.Create();
            var user = ctx.Users.Find(User.Identity.GetUserId());

            if (ModelState.IsValid)
            {
                user.PhoneNumber = model.PhoneNumber;
                ctx.SaveChanges();
                return(RedirectToAction("Index", new { Message = ManageMessageId.ChangePhoneSuccess }));
            }

            else
            {
                //   ModelState.AddModelError("", "Email is not good.");
                return(View(model));
            }
        }
示例#5
0
        public OptResult ChangePhone(ChangePhoneViewModel vmChangePhone)
        {
            OptResult rst = null;

            if (vmChangePhone == null)
            {
                rst = OptResult.Build(ResultCode.ParamError, "参数不能为空");
                return(rst);
            }
            if (ModelState.IsValid == false)
            {
                rst = OptResult.Build(ResultCode.ParamError, ModelState.Parse());
                return(rst);
            }

            rst = _srv.ChangePhone(vmChangePhone.idcard, vmChangePhone.phone);

            return(rst);
        }
        public ActionResult ChangePhone(ChangePhoneViewModel model)
        {
            using (VolunteersDBEntities db = new VolunteersDBEntities())
            {
                if (PhoneValidation(model.Phone))
                {
                    Volunteer currentUser = db.Volunteers.FirstOrDefault(u => u.Email == User.Identity.Name);
                    if (currentUser != null)
                    {
                        currentUser.Phone = model.Phone;
                        db.SaveChanges();
                        return(View("ChangePhoneConfirmation"));
                    }
                }
            }
            string message = "Invalid phone number entered. Do not use - and make sure your phone number is 10 digits long.";

            ViewBag.Message = message;
            return(View());
        }
示例#7
0
        public async Task <ActionResult> ChangePhone(ChangePhoneViewModel model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }
            var         userId = User.Identity.GetUserId();
            var         user   = UserManager.FindById(userId);
            Identifiers id     = user.Identifier;

            id.Phone        = model.Phone;
            user.Identifier = id;
            var result = await UserManager.UpdateAsync(user);

            if (result.Succeeded)
            {
                return(RedirectToAction("Index", new { Message = ManageMessageId.ChangePhoneSuccess }));
            }
            AddErrors(result);
            return(View(model));
        }
        public async Task <ActionResult> ChangePhone(ChangePhoneViewModel model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }

            var user = Session["user"] as TblUser;

            if (model.OldPhone.Equals(user.Phone))
            {
                user.Phone = model.NewPhone;

                zTest2DBEntities db = new zTest2DBEntities();

                db.TblUsers.Find(user.UserId).Phone = model.NewPhone;

                db.SaveChanges();
            }

            return(RedirectToAction("Index", "Manage"));
        }
示例#9
0
        public async Task <ActionResult> ChangePhone(ChangePhoneViewModel model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }

            var user = await UserManager.FindByIdAsync(User.Identity.GetUserId());

            user.PhoneNumber = model.Phone;

            var result = await UserManager.UpdateAsync(user);

            if (result.Succeeded)
            {
                await SignInManager.SignInAsync(user, isPersistent : false, rememberBrowser : false);

                return(RedirectToAction("Profile", "Account"));
            }

            AddErrors(result);

            return(View(model));
        }