コード例 #1
0
        public ActionResult UserProfile(UserProfileModel userProfileModel)
        {
            BackendlessUser user = Backendless.UserService.CurrentUser;
            if (user == null)
            {
                return RedirectToAction("Index", "Home");
            }
            if (ModelState.IsValid)
            {
                try
                {
                    string loggedInUserName = (string) user.Properties["login"];
                    Backendless.UserService.Login(loggedInUserName, userProfileModel.OldPassword);
                    user.Password = userProfileModel.NewPassword;
                    user.SetProperty("name", userProfileModel.Name);
                    user.SetProperty("surname", userProfileModel.Surname);
                    user.SetProperty("email", userProfileModel.Email);
                    Backendless.UserService.Update(user);
                    ModelState.AddModelError("", "Zaktualizowano dane użytkownika.");

                }
                catch (BackendlessException exception)
                {
                    if (exception.FaultCode == "3003")
                    {
                        ModelState.AddModelError("", "Błędne hasło użytkownika.");
                    }
                    else
                    {
                        ModelState.AddModelError("", exception.ToString());
                    }
                }
            }
            return View(userProfileModel);
        }
コード例 #2
0
        public ActionResult UserProfile()
        {
            BackendlessUser user = Backendless.UserService.CurrentUser;
            if (user == null)
            {
                return RedirectToAction("Index", "Home");
            }
            UserProfileModel userProfileModel = new UserProfileModel();

            userProfileModel.Email = (string)user.Properties["email"];
            userProfileModel.Name = (string)user.Properties["name"];
            userProfileModel.Surname = (string)user.Properties["surname"];

            return View(userProfileModel);
        }