Exemplo n.º 1
0
        public ActionResult UpdateUserProfile(UpdateProfileViewModel vm)
        {
            using (var client = new UserProfileServiceReference.UserProfileServiceClient())
            {
                int.TryParse(Session["UserId"].ToString(), out int userid);

                var Userinfo   = client.GetUserByUserId(userid);
                var updateUser = new UserProfileServiceReference.User()
                {
                    Address            = vm.userAddress,
                    City               = vm.userCity,
                    PersonalCodeNumber = vm.personalnumber,
                    Phonenumber        = vm.userPhoneNumber,
                    Picture            = vm.userProfilePicture,
                    ZipCode            = vm.userZipCode,
                    Id       = userid,
                    Email    = Userinfo.Email,
                    Name     = Userinfo.Name,
                    Surname  = Userinfo.Surname,
                    Username = Userinfo.Username,
                };

                var user = client.UpdateUser(updateUser);
            }

            return(View());
        }
Exemplo n.º 2
0
        public string Post([FromBody] RegisterParams register)
        {
            string username = register.Username;
            string password = register.Password;
            string email    = register.Email;

            using (UserProfileServiceReference.UserProfileManagementServiceClient client = new UserProfileServiceReference.UserProfileManagementServiceClient())
            {
                string status_msg     = null;
                bool   username_taken = client.IsUsernameTaken(username);
                bool   email_exists   = client.UserWithEmailIdExists(email);
                if (username_taken)
                {
                    status_msg = "This username is unavailable :/. ";
                    throw new HttpResponseException(SetHttpErrorMsg(status_msg, HttpStatusCode.BadRequest));
                }
                if (email_exists)
                {
                    status_msg = "An account with this email already exists -.- ";
                    throw new HttpResponseException(SetHttpErrorMsg(status_msg, HttpStatusCode.BadRequest));
                }
                UserProfileServiceReference.User user = new UserProfileServiceReference.User();
                user.Username = username;
                user.Password = password;
                user.EmailID  = email;
                client.RegisterUser(user);
                status_msg = "Registration Successful!";
                return(status_msg);
            }
        }
Exemplo n.º 3
0
        public ActionResult EditProfile(EditProfileViewModel vm)
        {
            using (var client = new UserProfileServiceReference.UserProfileServiceClient())
            {
                int.TryParse(Session["UserId"].ToString(), out int userid);
                var Userinfo = client.GetUserByUserId(userid);

                var updateUser = new UserProfileServiceReference.User()
                {
                    PersonalCodeNumber = vm.PersonalCodeNumber,
                    Address            = vm.UserAddress,
                    City        = vm.UserCity,
                    Phonenumber = vm.UserPhoneNumber,
                    Picture     = vm.UserProfilePicture,
                    ZipCode     = vm.UserZipCode,
                    Id          = userid,
                    Email       = Userinfo.Email,
                    Name        = Userinfo.Name,
                    Surname     = Userinfo.Surname,
                    Username    = Userinfo.Username,
                };

                var user = client.UpdateUser(updateUser);
            }

            if (!ModelState.IsValid)
            {
                return(View());
            }
            else
            {
                return(RedirectToAction("Index"));
            }
        }
Exemplo n.º 4
0
        public ActionResult ShowReviewsAboutUserId(int id)
        {
            UserProfileServiceReference.User obj = new UserProfileServiceReference.User();

            obj = clien2.GetUserByUserId(id);

            if (obj == null)
            {
                ViewBag.aboutuser = id;
            }
            else
            {
                ViewBag.aboutuser = obj.Username;
            }

            List <ReviewServiceReference.ReviewData> reviewList = client.GetReviewsByAboutUserId(id).ToList();

            return(View(reviewList));
        }
        public ActionResult UpdateAccountInformation(EditProfileViewModel vm)
        {
            using (var client = new UserProfileServiceReference.UserProfileServiceClient())
            {
                var updateUser = new UserProfileServiceReference.User()
                {
                    Address     = vm.UserAddress,
                    City        = vm.UserCity,
                    Email       = vm.UserEmail,
                    Phonenumber = vm.UserPhoneNumber,
                    Picture     = vm.UserProfilePicture,
                    ZipCode     = vm.UserZipCode,
                    Id          = vm.UserId,
                };

                var user = client.UpdateUser(updateUser);
            }

            return(View("Index"));
        }
Exemplo n.º 6
0
        public ActionResult UpdateUserProfile(UpdateProfileViewModel vm)
        {
            using (var client = new UserProfileServiceReference.UserProfileServiceClient())
            {
                int.TryParse(Session["UserId"].ToString(), out int userid);

                var Userinfo   = client.GetUserByUserId(userid);
                var updateUser = new UserProfileServiceReference.User()
                {
                    Address            = vm.userAddress,
                    City               = vm.userCity,
                    PersonalCodeNumber = vm.personalnumber,
                    Phonenumber        = vm.userPhoneNumber,
                    Picture            = vm.userProfilePicture,
                    ZipCode            = vm.userZipCode,
                    Id       = userid,
                    Email    = Userinfo.Email,
                    Name     = Userinfo.Name,
                    Surname  = Userinfo.Surname,
                    Username = Userinfo.Username,
                };

                var user = client.UpdateUser(updateUser);
            }

            using (var client = new UserLoginServiceReference.LoginServiceClient())
            {
                if (client.UsernameExist(vm.username))
                {
                    ViewBag.Message = "Det valda Användarnamnet finns redan";
                }
                else
                {
                    return(RedirectToAction("Index", "UserProfile"));
                }
            }
            return(View());
        }