Exemplo n.º 1
0
        public ActionResult ChangeInfo(ChangeInfoViewModel model)
        {
            if (!this.ModelState.IsValid)
            {
                this.TempData["Error"] = "Error.";
                return(this.RedirectToAction("Index"));
            }

            var monthDaysCount = DateTime.DaysInMonth(model.BirthYear, model.BirthMonth);
            var birthDate      = new DateTime(model.BirthYear, model.BirthMonth, model.BirthDay > monthDaysCount ? monthDaysCount : model.BirthDay);

            model.BirthDate = birthDate;

            var    value        = Enum.Parse(typeof(PhoneNumberCountryCode), Convert.ToString(model.PhoneNumberCountryCode));
            int    integerValue = (int)value;
            string PhoneNumber  = "+" + integerValue + "-" + Convert.ToString(model.PhoneNumber);

            model.PhoneNumber = PhoneNumber;

            var user = this.Mapper.Map <User>(model);

            this.usersService.Update(this.User.Identity.GetUserId(), user);

            this.TempData["Success"] = "Profile information has been updated.";

            return(this.RedirectToAction("Index"));
        }
Exemplo n.º 2
0
        public async Task <ActionResult> ChangeInfo(ChangeInfoViewModel model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }

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

            if (user == null)
            {
                return(RedirectToAction("Login", "Account"));
            }
            else
            {
                user.Email    = model.Email;
                user.FullName = model.FullName;
                var result = await UserManager.UpdateAsync(user);

                if (result.Succeeded)
                {
                    return(RedirectToAction("Index", new { Message = ManageMessageId.ChangeInformationSuccess }));
                }
                else
                {
                    AddErrors(result);
                    return(View(model));
                }
            }
        }
Exemplo n.º 3
0
        public ActionResult ChangeInfo(ChangeInfoViewModel model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }
            var uid = GetCurUserId();

            if (uid > 0 && !string.IsNullOrEmpty(model.Email) && !string.IsNullOrEmpty(model.RealName))
            {
                var member = MemberService.GetMemberFromUser(uid);
                if (member != null && member.Id > 0)
                {
                    member.Addr     = model.Addr;
                    member.Email    = model.Email;
                    member.Mobile   = model.Mobile;
                    member.QQ       = model.QQ;
                    member.RealName = model.RealName;
                    member.Remark   = model.Other;
                    member.Tel      = model.Tel;
                    member.Wechat   = model.Wechat;
                    DBService.UpdateEntity <St_member>(member);
                }
                return(RedirectToAction("Index"));
            }
            ModelState.AddModelError("", "无法修改联系方式!");
            return(View(model));
        }
 public ChangeInfo()
 {
     InitializeComponent();
     DataContext = new ChangeInfoViewModel()
     {
         Window = this
     };
 }
Exemplo n.º 5
0
        //
        // GET: /Manage/ChangeInfo
        public ActionResult ChangeInfo()
        {
            var user = UserManager.FindById(User.Identity.GetUserId());
            ChangeInfoViewModel model = new ChangeInfoViewModel();

            model.FullName = user.FullName;
            model.Email    = user.Email;
            return(View(model));
        }
Exemplo n.º 6
0
        public IActionResult ChangeInfo()
        {
            var model = new ChangeInfoViewModel
            {
                FullName = _userRepo.Get(GetCurrentUserAsync().Result.Id).FullName
            };

            return(View(model));
        }
        //
        // GET: /Manage/ChangeInfo
        public ActionResult ChangeInfo()
        {
            ApplicationUser     user  = db.Users.Find(User.Identity.GetUserId());
            ChangeInfoViewModel model = new ChangeInfoViewModel();

            model.NewFirstName   = user.FirstName;
            model.NewLastName    = user.LastName;
            model.NewPhoneNumber = user.PhoneNumber;
            return(View(model));
        }
Exemplo n.º 8
0
        // GET: /Manage/ChangeName
        public async Task <ActionResult> ChangeInfo()
        {
            var user = await UserManager.FindByIdAsync(User.Identity.GetUserId());

            var model = new ChangeInfoViewModel
            {
                Name    = user.Name,
                Surname = user.Surname,
                Email   = user.Email
            };

            return(View(model));
        }
Exemplo n.º 9
0
        public async Task <ActionResult> UserProps(ChangeInfoViewModel model)
        {
            AppUser user = CurrentUser;

            user.Gender    = model.Gender;
            user.Signature = model.Signature;
            user.RealName  = model.RealName;
            user.Age       = model.Age;
            user.IDCardNO  = model.IDCardNO;
            await UserManager.UpdateAsync(user);

            return(View(user));
        }
Exemplo n.º 10
0
        public async Task <ActionResult> ChangeInfo(ChangeInfoViewModel model)
        {
            FirebaseClient firebase = CustomAuth.firebase;

            if (ModelState.IsValid)
            {
                var userAuth = CustomAuth.UserAuth;
                FirebaseObject <CustomerAccount> item = await getUserFromFirebase(userAuth.User.Email);

                CustomerAccount acc = item.Object;
                // update informations
                if (model.Number != null)
                {
                    acc.PhoneNumber = model.Number;
                }

                if (model.Name != null)
                {
                    if (model.Name.Any(char.IsDigit) == false)
                    {
                        acc.Name = model.Name;
                    }
                    else
                    {
                        ViewBag.Message = "Name can not have any number";
                        return(View());
                    }
                }
                if (model.Surname != null)
                {
                    if (model.Surname.Any(char.IsDigit) == false)
                    {
                        acc.Surname = model.Surname;
                    }
                    else
                    {
                        ViewBag.Message = "Surname can not have any number";
                        return(View());
                    }
                }
                acc.UserName = userAuth.User.Email;
                await firebase.Child("UserAccount").Child(item.Key).PutAsync(acc);

                // print message
                ViewBag.Message = "Changed";
                return(View());
            }
            return(View());
        }
        public ActionResult ChangeInfo(ChangeInfoViewModel model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }
            ApplicationUser user = db.Users.Find(User.Identity.GetUserId());

            user.FirstName = model.NewFirstName;
            db.Entry(user).Property("FirstName").IsModified = true;
            db.SaveChanges();
            user.LastName = model.NewLastName;
            db.Entry(user).Property("LastName").IsModified = true;
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Exemplo n.º 12
0
        public async Task <ActionResult> ChangeInfo(ChangeInfoViewModel model)
        {
            if (ModelState.IsValid)
            {
                var user = await UserManager.FindByIdAsync(User.Identity.GetUserId());

                if (user == null)
                {
                    return(RedirectToAction("ChangeInfo", new { message = ManageMessageId.Error }));
                }

                user.FirstName  = model.FirstName;
                user.LastName   = model.LastName;
                user.Country    = model.Country;
                user.Biography  = CloseAllTags(SanitizeHtml(model.Biography));
                user.UserGender = model.UserGender;
                user.Birthday   = new DateTime(model.Year, model.Month, model.Day);
                if (user.Email != model.Email)
                {
                    user.Email          = model.Email;
                    user.EmailConfirmed = false;
                }

                var result = await UserManager.UpdateAsync(user);

                if (result.Succeeded)
                {
                    return(RedirectToAction("ChangeInfo", new { message = ManageMessageId.ChangeInfoSuccess }));
                }
                else
                {
                    return(RedirectToAction("ChangeInfo", new { message = ManageMessageId.Error }));
                }
            }

            model.YearList = Enumerable.Range(DateTime.Now.Year - 100, 100).Select(i => new SelectListItem {
                Value = i.ToString(), Text = i.ToString()
            }).Reverse();
            model.MonthList = Enumerable.Range(1, 12).Select(i => new SelectListItem {
                Value = i.ToString(), Text = i.ToString()
            });
            model.DayList = Enumerable.Range(1, 31).Select(i => new SelectListItem {
                Value = i.ToString(), Text = i.ToString()
            });

            return(View(model));
        }
Exemplo n.º 13
0
        public async Task <ActionResult> ChangeInfo(ChangeInfoViewModel model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }

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

            user.Name     = model.Name;
            user.Surname  = model.Surname;
            user.Email    = model.Email;
            user.UserName = model.Email;
            await UserManager.UpdateAsync(user);

            return(RedirectToAction("Index", new { Message = ManageMessageId.ChangeInfoSuccess }));
        }
Exemplo n.º 14
0
        public async Task <IActionResult> ChangeInfo(ChangeInfoViewModel vm)
        {
            if (ModelState.IsValid)
            {
                var account = await userManager.GetUserAsync(User);

                var passwordValidator = HttpContext.RequestServices.GetService(typeof(IPasswordValidator <Account>)) as IPasswordValidator <Account>;
                var passwordHasher    = HttpContext.RequestServices.GetService(typeof(IPasswordHasher <Account>)) as IPasswordHasher <Account>;
                var result            = await passwordValidator.ValidateAsync(userManager, account, vm.NewPassword);

                if (result.Succeeded)
                {
                    account.PasswordHash = passwordHasher.HashPassword(account, vm.NewPassword);
                    await userManager.UpdateAsync(account);

                    return(RedirectToAction("Index", "Home"));
                }
            }
            return(View(vm));
        }
Exemplo n.º 15
0
        //
        // GET: /Manage/ChangeInfo
        public ActionResult ChangeInfo(ManageMessageId?message)
        {
            ViewBag.StatusMessage =
                message == ManageMessageId.ChangeInfoSuccess ? "Your information has been changed."
                : message == ManageMessageId.EmailSent ? "E-mail successfully sent"
                : message == ManageMessageId.Error ? "An error has occurred."
                : "";

            var model = new ChangeInfoViewModel();

            model.HasPassword = false;
            model.UserGender  = UserGender.Male;
            model.YearList    = Enumerable.Range(DateTime.Now.Year - 100, 100).Select(i => new SelectListItem {
                Value = i.ToString(), Text = i.ToString()
            }).Reverse();
            model.MonthList = Enumerable.Range(1, 12).Select(i => new SelectListItem {
                Value = i.ToString(), Text = i.ToString()
            });
            model.DayList = Enumerable.Range(1, 31).Select(i => new SelectListItem {
                Value = i.ToString(), Text = i.ToString()
            });

            var user = UserManager.FindById(User.Identity.GetUserId());

            if (user != null)
            {
                model.HasPassword = user.PasswordHash != null;
                model.Email       = user.Email;
                model.HasVerified = user.EmailConfirmed;
                model.FirstName   = user.FirstName;
                model.LastName    = user.LastName;
                model.UserGender  = user.UserGender;
                model.Year        = user.Birthday.Year;
                model.Month       = user.Birthday.Month;
                model.Day         = user.Birthday.Day;
                model.Country     = user.Country;
                model.Biography   = user.Biography;
            }

            return(View(model));
        }
Exemplo n.º 16
0
        public async Task <IActionResult> ChangeInfo(ChangeInfoViewModel model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }

            ApplicationUser appuser = await GetCurrentUserAsync();

            if (appuser == null)
            {
                return(RedirectToAction(nameof(Index), new { Message = ManageMessageId.Error }));
            }

            User user = _userRepo.Get(GetCurrentUserAsync().Result.Id);

            user.FullName = model.FullName;

            _userRepo.Update(user);
            return(RedirectToAction(nameof(Index), new { Message = ManageMessageId.ChangeInfoSuccess }));
        }
Exemplo n.º 17
0
        //finds the id for the currently logged in user. sets the account information of the user according to the model (changeinfoviewmodel)
        public ActionResult ChangeInfo(ChangeInfoViewModel model)

        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }
            var infoContext = new ApplicationDbContext();
            var userId      = User.Identity.GetUserId();


            var currentProfile = infoContext.Users.FirstOrDefault(p => p.Id == userId);

            currentProfile.Firstname   = model.Firstname;
            currentProfile.Lastname    = model.Lastname;
            currentProfile.Age         = model.Age;
            currentProfile.Description = model.Description;

            infoContext.SaveChanges();
            return(View(model));
        }
Exemplo n.º 18
0
        public ActionResult ChangeInfo()
        {
            var vm  = new ChangeInfoViewModel();
            var uid = GetCurUserId();

            if (uid > 0)
            {
                var member = MemberService.GetMemberFromUser(uid);
                if (member != null && member.Id > 0)
                {
                    vm.Addr     = member.Addr;
                    vm.Email    = member.Email;
                    vm.Mobile   = member.Mobile;
                    vm.QQ       = member.QQ;
                    vm.RealName = member.RealName;
                    vm.Other    = member.Remark;
                    vm.Tel      = member.Tel;
                    vm.Wechat   = member.Wechat;
                }
            }
            return(View(vm));
        }
Exemplo n.º 19
0
 public async Task<ActionResult> ChangeInfo()
 {
     var user = await UserManager.FindByIdAsync(User.Identity.GetUserId());
     var info = new ChangeInfoViewModel {
         FirstName = user.FirstName,
         LastName = user.LastName,
         PreferredName = user.PreferredName,
         PhoneNumber = user.PhoneNumber
     };
     return View(info);
 }
Exemplo n.º 20
0
        public async Task<ActionResult> ChangeInfo(ChangeInfoViewModel userInfo)
        {
            if (ModelState.IsValid)
            {
                var user = await UserManager.FindByIdAsync(User.Identity.GetUserId());
                user.FirstName = userInfo.FirstName;
                user.LastName = userInfo.LastName;
                user.PreferredName = userInfo.PreferredName;
                user.PhoneNumber = userInfo.PhoneNumber;
                UserManager.Update(user);

                return RedirectToAction("Index");

            }

            return View(userInfo);
        }