Exemplo n.º 1
0
        public ActionResult ChangeEmail(ProfileViewModel email)
        {
            List<string> errors;
            if (Session["val"] != null)
            {
                errors = ((string[])Session["val"]).ToList();
            }
            else
            {
                errors = new List<string>();
            }
            UserDto user = new UserDto();

            user.Email = email.EmailAddress;

            if (_userService.ChangeEmail(user, User.Identity.Name))
            {
                errors.Add("Email został zmieniony.");
                Session["val"] = errors.ToArray<string>();
                return RedirectToAction("Profil", new
                {
                    User = User.Identity.Name
                });
            }
            else
            {
                errors.Add("Błąd. Email nie został zmieniony.");
                Session["val"] = errors.ToArray<string>();
                return RedirectToAction("Profil", new
                {
                    User = User.Identity.Name
                });
            }
        }
Exemplo n.º 2
0
        public ActionResult Profil(string user)
        {
            ProfileViewModel profilView = new ProfileViewModel();

            int buildings = 0;
            var userDto = _userService.Profil(user);

            profilView.User_ID = userDto.ID;

            profilView.Login = userDto.Login;
            profilView.EmailAddress = userDto.Email;
            profilView.RegDays = (DateTime.Now - userDto.Registration_Date).Days;
            profilView.LogDays = (DateTime.Now - userDto.Last_Log).Days;
            profilView.Value = _userService.ifFriend(User.Identity.Name, user);
            profilView.IfIgnored = _userService.Ignored(user, User.Identity.Name);
            profilView.Ignor = _userService.Ignored(User.Identity.Name, user);

            profilView.Ignored_Login = _userService.GetIgnored(User.Identity.Name);

            profilView.Friend_Login = new List<string>();
            foreach (var item in _userService.GetFriendList(User.Identity.Name))
            {
                if (item.Friend_Login == User.Identity.Name)
                {
                    profilView.Friend_Login.Add(item.User_Login);
                }
                else
                {
                    profilView.Friend_Login.Add(item.Friend_Login);
                }
            }

            foreach (var item in _userBuildingService.GetUserBuildingList(user))
            {
                buildings += 1;
            }

            profilView.Number = buildings;

            profilView.allDiv = _tutorialService.tutorialUser(User.Identity.Name).allDiv;
            profilView.setDiv = _tutorialService.tutorialUser(User.Identity.Name).setDiv;

            return View(profilView);
        }
Exemplo n.º 3
0
        public ActionResult ChangePass(ProfileViewModel pass)
        {
            List<string> errors;
            if (Session["val"] != null)
            {
                errors = ((string[])Session["val"]).ToList();
            }
            else
            {
                errors = new List<string>();
            }

            UserDto user = new UserDto();

            user.OldPassword = pass.OldPassword;
            user.Password = pass.Password;

            if (_userService.ChangePass(user, User.Identity.Name))
            {
                errors.Add("Hasło zostało zmienione");
                Session["val"] = errors.ToArray<string>();
                return RedirectToAction("Profil", new
                {
                    User = User.Identity.Name
                });
            }
            else
            {
                errors.Add("Błąd. Hasło nie zostało zmienione.");
                Session["val"] = errors.ToArray<string>();
                return RedirectToAction("Profil", new
                {
                    User = User.Identity.Name
                });
            }
        }