public ProfileSettingsWindow(Window owner, ProfileSettingsViewModel viewModel)
        {
            InitializeComponent();

            _owner                 = owner;
            _viewModel             = viewModel;
            this.DataContext       = _viewModel;
            this.Closing          += (sender, e) => { _viewModel.OnCloseProfileSettingsWindowHandler(); e.Cancel = true; };
            this.IsVisibleChanged += (sender, e) =>
            {
                switch (Visibility)
                {
                case Visibility.Visible:
                    this.Owner     = _owner;
                    _owner.Opacity = 0.3;
                    break;

                case Visibility.Hidden:
                    _owner.Opacity = 1.0;
                    break;
                }
            };

            this.Topmost = true;
        }
Пример #2
0
        public ActionResult Settings(ProfileSettingsViewModel model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }

            string userId = User.Identity.GetUserId();
            GenericServiceResult result = profileService.UpdateUserProfile(model, userId);

            if (result == GenericServiceResult.Error)
            {
                Response.StatusCode = (int)HttpStatusCode.BadRequest;
                ModelState.AddModelError("Error", "Unknown error");
                return(View(model));
            }

            var identity = new ClaimsIdentity(User.Identity);

            identity.RemoveClaim(identity.FindFirst("Theme"));
            identity.AddClaim(new Claim("Theme", model.Theme));

            AuthenticationManager.AuthenticationResponseGrant =
                new AuthenticationResponseGrant(
                    new ClaimsPrincipal(identity),
                    new AuthenticationProperties {
            }
                    );

            return(View(model));
        }
        public void TestOnSubmitFail()
        {
            byte[] image = new byte[64 * 1024];

            Mock <IUserController> userControllerMock = new Mock <IUserController>(MockBehavior.Strict);

            userControllerMock.Setup(a => a.UpdateUser(It.IsAny <User>(), null)).Returns(Task.FromResult("ERROR"));

            Mock <IConstantUserInstance> constantUserMock = new Mock <IConstantUserInstance>(MockBehavior.Strict);

            constantUserMock.Setup(a => a.GetUser()).Returns(new User());
            constantUserMock.Setup(a => a.GetProfilePic()).Returns(image);

            Mock <IPhotoPickerService> photoPickerMock = new Mock <IPhotoPickerService>(MockBehavior.Strict);

            Mock <INavigationService> navigationMock = new Mock <INavigationService>(MockBehavior.Strict);

            ProfileSettingsViewModel viewModel = new ProfileSettingsViewModel(userControllerMock.Object,
                                                                              constantUserMock.Object, photoPickerMock.Object, navigationMock.Object);

            viewModel.OnSubmit();

            userControllerMock.Verify(a => a.UpdateUser(It.IsAny <User>(), null), Times.Once);
            Assert.AreEqual(viewModel.ErrorMessage, "ERROR");
            navigationMock.Verify(a => a.NavigateToHomePage(Constants.ProfileIndex), Times.Never);
        }
        DeleteProfile_TwoProfiles_ProfileWithoutPrinterMapping_QueryDeleteProfileReturnsTrue_CurrentProfileGetsDeleted
            ()
        {
            var secondProfile = new ConversionProfile();

            _settings.ConversionProfiles.Add(secondProfile);
            _settings.ApplicationSettings.LastUsedProfileGuid = secondProfile.Guid;

            _profileSettingsViewModel = CreateProfileSettingsViewModel(_settings);

            var functionsStub = MockRepository.GenerateStub <ITestFunctions>();

            functionsStub.Stub(x => x.ReturnsBoolWithoutParameters()).Return(true);
            _profileSettingsViewModel.QueryDeleteProfile = functionsStub.ReturnsBoolWithoutParameters;
            functionsStub.Stub(x => x.ReturnsBoolWithTwoStringParameters(null, null)).IgnoreArguments().Return(false);
            _profileSettingsViewModel.QueryDeleteProfileWithPrinterMapping =
                functionsStub.ReturnsBoolWithTwoStringParameters;

            _profileSettingsViewModel.DeleteProfileCommand.Execute(null);

            functionsStub.AssertWasCalled(x => x.ReturnsBoolWithoutParameters(), options => options.Repeat.Once());
            //QueryDeleteProfile
            functionsStub.AssertWasNotCalled(x => x.ReturnsBoolWithTwoStringParameters(null, null),
                                             options => options.IgnoreArguments()); //QueryDeleteProfileWithPrinterMapping

            Assert.IsFalse(_profileSettingsViewModel.Settings.ConversionProfiles.Contains(secondProfile),
                           "Current profile has not been deleted.");
            Assert.AreEqual(1, _profileSettingsViewModel.Settings.ConversionProfiles.Count,
                            "Wrong number of profiles after current profile should be deleted.");
            Assert.AreEqual(_originalFirstProfile, _profileSettingsViewModel.CurrentProfile,
                            "CurrentProfile is not the original first profile.");
        }
Пример #5
0
        public ActionResult ChangeProfile(ProfileSettingsViewModel model)
        {
            var user = UserManager.FindById(User.Identity.GetUserId());

            if (model.PhoneNumber != null)
            {
                user.Mobile = model.PhoneNumber;
            }
            if (model.Email != null)
            {
                user.Email = model.Email;
            }
            if (model.Address != null)
            {
                user.Address = model.Address;
            }
            if (model.NickName != null)
            {
                user.Nickname = model.NickName;
            }

            var result = UserManager.Update(user);

            CacheHelperApplicationUser.GetById(User.Identity.GetUserId()).Nickname = model.NickName;
            if (!result.Succeeded)
            {
                logger.Debug("Change profile failed!");
                SetErrorMessage();
            }
            SetSuccessMessage("New profile has been saved!");
            model.UserName    = user.UserName;
            model.PhoneNumber = user.Mobile;
            model.Email       = user.Email;
            return(View("ProfileSettings", model));
        }
        CloseWithSave_NoChangesInProfiles_DefectiveProfile_QueryIgnoreDefectiveProfilesReturnsFalse_CloseViewActionGetsBlocked_CheckForClosingDoesNotCallQueryDiscardChanges
            ()
        {
            var secondProfile = new ConversionProfile();

            _settings.ConversionProfiles.Add(secondProfile);
            _settings.ApplicationSettings.LastUsedProfileGuid = secondProfile.Guid;
            _settings.ConversionProfiles[0].CoverPage.Enabled = true;
            _settings.ConversionProfiles[0].CoverPage.File    = "String to a not existing path to get defective profile";

            _profileSettingsViewModel = CreateProfileSettingsViewModel(_settings.Copy());

            var functionsStub = MockRepository.GenerateStub <ITestFunctions>();

            functionsStub.Stub(x => x.ReturnsBoolWithActionResultDictParameter(null)).IgnoreArguments().Return(false);
            _profileSettingsViewModel.QueryIgnoreDefectiveProfiles =
                functionsStub.ReturnsBoolWithActionResultDictParameter;
            functionsStub.Stub(x => x.VoidFunctionWithBoolParameters(true));
            _profileSettingsViewModel.CloseViewAction     = functionsStub.VoidFunctionWithBoolParameters;
            _profileSettingsViewModel.QueryDiscardChanges = functionsStub.ReturnsBoolWithoutParameters;

            _profileSettingsViewModel.SaveButtonCommand.Execute(null);

            functionsStub.AssertWasCalled(x => x.ReturnsBoolWithActionResultDictParameter(null),
                                          options => options.IgnoreArguments().Repeat.Once()); //QueryIgnoreDefectiveProfiles
            functionsStub.AssertWasNotCalled(x => x.VoidFunctionWithBoolParameters(true));     //CloseViewAction

            Assert.AreEqual(_profileSettingsViewModel.Settings, _settings,
                            "Unchanged settings after saving are not the original settings.");

            _profileSettingsViewModel.CheckForClosingWindowAndRestoreTheSettings();
            functionsStub.AssertWasNotCalled(x => x.ReturnsBoolWithoutParameters()); //QueryDiscardChanges
        }
Пример #7
0
        public ActionResult ChangePassword(ProfileSettingsViewModel model)
        {
            var db   = new ApplicationDbContext();
            var user = db.Users.FirstOrDefault(c => c.UserName == model.UserName);

            HTMLHelper.BindModel(user);
            try
            {
                db.SaveChanges();
                var password = model.Password;
                if (password.IsNotNullOrEmpty())
                {
                    UserManager.RemovePassword(user.Id);
                    UserManager.AddPassword(user.Id, password);
                    SetSuccessMessage("New password has been saved!");
                }
                else
                {
                    SetSuccessMessage();
                }
            }
            catch (Exception e)
            {
                logger.Debug("Change password Failed!", e);
                SetErrorMessage();
            }

            return(View("Overall"));
        }
        public OperationResult <ProfileSettingsViewModel> GetUserProfile(string userId)
        {
            try
            {
                UserProfile  profile  = unitOfWork.ClientManager.GetProfile(userId);
                UserSettings settings = unitOfWork.ClientManager.GetSettings(userId);

                ProfileSettingsViewModel model = new ProfileSettingsViewModel
                {
                    Name  = profile.Name,
                    About = profile.About,
                    Icon  = profile.Icon,
                    EmailNotifications = settings.EmailNotification,
                    Theme = settings.Theme
                };

                return(new OperationResult <ProfileSettingsViewModel> {
                    Model = model, Message = GenericServiceResult.Success
                });
            }
            catch
            {
                return(new OperationResult <ProfileSettingsViewModel> {
                    Model = null, Message = GenericServiceResult.Error
                });
            }
        }
Пример #9
0
        public async Task <ActionResult> Settings()
        {
            var user = await userMgr.FindByNameAsync(User.Identity.Name);

            var model = new ProfileSettingsViewModel
            {
                FirstName = user.FirstName,
                LastName  = user.LastName,
                Birthday  = user.Birthday
            };

            List <CinemaEntity> listCinema = new List <CinemaEntity> {
                new CinemaEntity {
                    Id = 0, Name = "Не вибрано"
                }
            };

            listCinema.AddRange(cinemaRepository.GetAll());
            List <City> listCity = new List <City> {
                new City {
                    Id = 0, Name = "Не вибрано"
                }
            };

            listCity.AddRange(cityRepository.GetAll());
            int userFavoriteCinema = (user.FavotiteCinema == null) ? 0 : user.FavotiteCinema.Id;
            int userCity           = (user.City == null) ? 0 : user.City.Id;

            ViewBag.FavoriteCinemaId = new SelectList(listCinema, "id", "name", userFavoriteCinema);
            ViewBag.CityId           = new SelectList(listCity, "id", "name", userCity);

            return(View(model));
        }
        DeleteProfile_ProfileWithoutPrinterMapping_TwoProfiles_QueryDeleteProfileReturnsFalse_DeletionGetsCanceled_()
        {
            var secondProfile = new ConversionProfile();

            _settings.ConversionProfiles.Add(secondProfile);
            _settings.ApplicationSettings.LastUsedProfileGuid = secondProfile.Guid;

            _profileSettingsViewModel = CreateProfileSettingsViewModel(_settings);

            var functionsStub = MockRepository.GenerateStub <ITestFunctions>();

            functionsStub.Stub(x => x.ReturnsBoolWithoutParameters()).Return(false);
            _profileSettingsViewModel.QueryDeleteProfile = functionsStub.ReturnsBoolWithoutParameters;
            functionsStub.Stub(x => x.ReturnsBoolWithTwoStringParameters(null, null)).IgnoreArguments().Return(false);
            _profileSettingsViewModel.QueryDeleteProfileWithPrinterMapping =
                functionsStub.ReturnsBoolWithTwoStringParameters;

            _profileSettingsViewModel.DeleteProfileCommand.Execute(null);

            functionsStub.AssertWasCalled(x => x.ReturnsBoolWithoutParameters(), options => options.Repeat.Once());
            //QueryDeleteProfile
            functionsStub.AssertWasNotCalled(x => x.ReturnsBoolWithTwoStringParameters(null, null),
                                             options => options.IgnoreArguments()); //QueryDeleteProfileWithPrinterMapping

            Assert.IsTrue(_profileSettingsViewModel.Settings.ConversionProfiles.Contains(secondProfile),
                          "Current profile was deleted although deletion was canceled.");
            Assert.AreEqual(2, _profileSettingsViewModel.Settings.ConversionProfiles.Count,
                            "Wrong number of profiles after canceled deletion.");
            Assert.AreEqual(secondProfile, _profileSettingsViewModel.CurrentProfile,
                            "Wrong CurrentProfile after canceled deletion.");
        }
        public void TestOnChangeProfilePic()
        {
            Mock <Stream> streamMock = new Mock <Stream>(MockBehavior.Strict);

            byte[] image = new byte[64 * 1024];

            Mock <IUserController> userControllerMock = new Mock <IUserController>(MockBehavior.Strict);

            userControllerMock.Setup(a => a.ChangeProfilePicture(It.IsAny <string>(), It.IsAny <Stream>()))
            .Returns(Task.FromResult(""));

            Mock <IConstantUserInstance> constantUserMock = new Mock <IConstantUserInstance>(MockBehavior.Strict);

            constantUserMock.Setup(a => a.GetUser()).Returns(new User());
            constantUserMock.Setup(a => a.GetProfilePic()).Returns(image);

            Mock <IPhotoPickerService> photoPickerMock = new Mock <IPhotoPickerService>(MockBehavior.Strict);

            photoPickerMock.Setup(a => a.GetImageStreamAsync()).Returns(Task.FromResult(streamMock.Object));

            Mock <INavigationService> navigationMock = new Mock <INavigationService>(MockBehavior.Strict);

            ProfileSettingsViewModel viewModel = new ProfileSettingsViewModel(userControllerMock.Object,
                                                                              constantUserMock.Object, photoPickerMock.Object, navigationMock.Object);

            viewModel.OnChangeProfilePic();

            photoPickerMock.Verify(a => a.GetImageStreamAsync(), Times.Once);
            userControllerMock.Verify(a => a.ChangeProfilePicture(It.IsAny <string>(), It.IsAny <Stream>()), Times.Once);
            //Once from Init function and one in change profile pic function
            constantUserMock.Verify(a => a.GetProfilePic(), Times.Exactly(2));
        }
        DeleteProfile_TwoProfiles_ProfileWithPrinterMapping_QueryDeleteProfileWithPrinterMappingReturnsTrue_CurrentProfileGetsDeleted
            ()
        {
            var secondProfile = new ConversionProfile();

            _settings.ConversionProfiles.Add(secondProfile);
            _settings.ApplicationSettings.LastUsedProfileGuid = secondProfile.Guid;
            var printerMapping = new PrinterMapping();

            printerMapping.PrinterName = "fake printer";
            printerMapping.ProfileGuid = _settings.ApplicationSettings.LastUsedProfileGuid;
            _settings.ApplicationSettings.PrinterMappings.Add(printerMapping);

            _profileSettingsViewModel = CreateProfileSettingsViewModel(_settings);

            _interactionInvoker.HandleMessageInteraction = interaction => { interaction.Response = MessageResponse.Yes; };

            _profileSettingsViewModel.DeleteProfileCommand.Execute(null);

            Assert.IsFalse(_profileSettingsViewModel.Settings.ConversionProfiles.Contains(secondProfile),
                           "Current profile has not been deleted.");
            Assert.AreEqual(1, _profileSettingsViewModel.Settings.ConversionProfiles.Count,
                            "Wrong number of profiles after current profile should be deleted.");
            Assert.AreEqual(_originalFirstProfile, _profileSettingsViewModel.CurrentProfile,
                            "CurrentProfile is not the original first profile.");
        }
        public void CloseWithSave_ChangesInProfiles_NoDefectiveProfile_CloseViewActionGetsCalled()
        {
            var secondProfile = new ConversionProfile();

            _settings.ConversionProfiles.Add(secondProfile);
            _settings.ApplicationSettings.LastUsedProfileGuid = secondProfile.Guid;

            _profileSettingsViewModel = CreateProfileSettingsViewModel(_settings.Copy());

            var functionsStub = MockRepository.GenerateStub <ITestFunctions>();

            functionsStub.Stub(x => x.ReturnsBoolWithActionResultDictParameter(null)).IgnoreArguments().Return(false);
            _profileSettingsViewModel.QueryIgnoreDefectiveProfiles =
                functionsStub.ReturnsBoolWithActionResultDictParameter;
            functionsStub.Stub(x => x.VoidFunctionWithBoolParameters(true));
            _profileSettingsViewModel.CloseViewAction = functionsStub.VoidFunctionWithBoolParameters;

            _profileSettingsViewModel.Settings.ConversionProfiles[0].AuthorTemplate +=
                "Change the Author to change the Settings";
            var changedSettings = _profileSettingsViewModel.Settings.Copy();

            _profileSettingsViewModel.SaveButtonCommand.Execute(null);

            functionsStub.AssertWasNotCalled(x => x.ReturnsBoolWithActionResultDictParameter(null));
            //QueryIgnoreDefectiveProfiles
            functionsStub.AssertWasCalled(x => x.VoidFunctionWithBoolParameters(true), options => options.Repeat.Once());
            //CloseViewAction

            Assert.AreEqual(_profileSettingsViewModel.Settings, changedSettings,
                            "Settings after saving are not the changed settings.");
        }
        DeleteProfile_TwoProfiles_ProfileWithPrinterMapping_QueryDeleteProfileWithPrinterMappingReturnsFalse_DeletionGetsCanceled
            ()
        {
            var secondProfile = new ConversionProfile();

            _settings.ConversionProfiles.Add(secondProfile);
            _settings.ApplicationSettings.LastUsedProfileGuid = secondProfile.Guid;
            var printerMapping = new PrinterMapping();

            printerMapping.PrinterName = "fake printer";
            printerMapping.ProfileGuid = _settings.ApplicationSettings.LastUsedProfileGuid;
            _settings.ApplicationSettings.PrinterMappings.Add(printerMapping);

            _profileSettingsViewModel = CreateProfileSettingsViewModel(_settings);

            _interactionInvoker.HandleMessageInteraction = interaction => { interaction.Response = MessageResponse.No; };

            _profileSettingsViewModel.DeleteProfileCommand.Execute(null);

            Assert.IsTrue(_profileSettingsViewModel.Settings.ConversionProfiles.Contains(secondProfile),
                          "Current profile was deleted although deletion was canceled.");
            Assert.AreEqual(2, _profileSettingsViewModel.Settings.ConversionProfiles.Count,
                            "Wrong number of profiles after canceled deletion.");
            Assert.AreEqual(secondProfile, _profileSettingsViewModel.CurrentProfile,
                            "Wrong CurrentProfile after canceled deletion.");
        }
        public void CheckForClosing_ChangesInProfiles_QueryDiscardChangesReturnsFalse_ClosingGetsBlocked()
        {
            var secondProfile = new ConversionProfile();

            _settings.ConversionProfiles.Add(secondProfile);
            _settings.ApplicationSettings.LastUsedProfileGuid = secondProfile.Guid;

            _profileSettingsViewModel = CreateProfileSettingsViewModel(_settings.Copy());

            var functionsStub = MockRepository.GenerateStub <ITestFunctions>();

            functionsStub.Stub(x => x.ReturnsBoolWithoutParameters()).Return(false);
            _profileSettingsViewModel.QueryDiscardChanges = functionsStub.ReturnsBoolWithoutParameters;

            _profileSettingsViewModel.Settings.ConversionProfiles[0].AuthorTemplate +=
                "Change the Author to change the Settings";
            var changedSettings = _profileSettingsViewModel.Settings.Copy();

            Assert.IsFalse(_profileSettingsViewModel.CheckForClosingWindowAndRestoreTheSettings(),
                           "Closing the window should be blocked.");
            functionsStub.AssertWasCalled(x => x.ReturnsBoolWithoutParameters(), options => options.Repeat.Once());
            //QueryDiscardChanges
            Assert.AreEqual(_profileSettingsViewModel.Settings, changedSettings,
                            "Settings after blocked closing are not the changed settings.");
        }
 public ProfileSettingsWindow(ProfileSettingsViewModel profileSettingsViewModel, ActionControlsBundle actionControls, IUserGuideHelper userGuideHelper)
 {
     _userGuideHelper = userGuideHelper;
     DataContext      = profileSettingsViewModel;
     InitializeComponent();
     AddActions(actionControls);
 }
Пример #17
0
        public ActionResult Edit(ProfileSettingsViewModel model)
        {
            var customerID = User.Identity.GetUserId();

            if (ModelState.IsValid)
            {
                try
                {
                    var customer = _userManager.Users.Where(u => u.Id == customerID).First();
                    customer.FirstName = model.Name;
                    customer.LastName  = model.Family;
                    _ticketRepo.CommitChanges();
                }
                catch
                {
                    ModelState.AddModelError("", "Update failed.");
                }
            }
            else
            {
                ModelState.AddModelError("", "Invalid data.");
            }
            return(View(_userManager.Users
                        .Where(u => u.Id == customerID)
                        .Select(u => new ProfileSettingsViewModel
            {
                Name = u.FirstName,
                Family = u.LastName,
                UserName = u.UserName,
            }).FirstOrDefault()));
        }
        public void CurrentProfileIsRenameable_RenameProfileCanExecuteIsEnabled()
        {
            _profileSettingsViewModel = CreateProfileSettingsViewModel(_settings);

            _profileSettingsViewModel.CurrentProfile.Properties.Renamable = true;
            Assert.IsTrue(_profileSettingsViewModel.RenameProfileCommand.CanExecute(null),
                          "RenameProfileCommand is not executable for enabled renamable property");
        }
        public void CurrentProfileIsNotRenameable_RenameProfileCanExecuteIsDisabled()
        {
            _profileSettingsViewModel = CreateProfileSettingsViewModel(_settings);

            _profileSettingsViewModel.CurrentProfile.Properties.Renamable = false;
            Assert.IsFalse(_profileSettingsViewModel.RenameProfileCommand.CanExecute(null),
                           "RenameProfileCommand is executable for disabled renamable property");
        }
        public void DeleteProfile_OnlyOneProfile_ProfileIsNotDeletable_DeleteProfileCommandIsNotExecutable()
        {
            _profileSettingsViewModel = CreateProfileSettingsViewModel(_settings);

            _profileSettingsViewModel.CurrentProfile.Properties.Deletable = false;
            Assert.IsFalse(_profileSettingsViewModel.DeleteProfileCommand.CanExecute(null),
                           "Last profile must not be deleted even if deletable property is enabled.");
        }
        public void ProfileNameIsValid_Test()
        {
            _profileSettingsViewModel = CreateProfileSettingsViewModel(_settings);

            Assert.IsTrue(_profileSettingsViewModel.ProfilenameIsValid(NewProfileName).IsValid,
                          "Not existing profile name must be valid.");
            Assert.IsTrue(_profileSettingsViewModel.ProfilenameIsValid(OriginalProfileName + " appendix").IsValid,
                          "Existing profile with appendix must be valid.");
            Assert.IsFalse(_profileSettingsViewModel.ProfilenameIsValid(OriginalProfileName).IsValid,
                           "Existing profile name must be invalid.");
        }
Пример #22
0
        public async Task <IActionResult> ProfileSettings(string id)
        {
            User user = await _userManager.FindByIdAsync(id);

            if (user == null)
            {
                return(NotFound());
            }
            ProfileSettingsViewModel model = _mapper.Map <ProfileSettingsViewModel>(user);

            return(View(model));
        }
        public void DeleteProfile_TwoProfiles_CurrentProfileWithEnabledDeletable_DeleteProfileCommandIsExecutable()
        {
            var secondProfile = new ConversionProfile();

            secondProfile.Properties.Deletable = true;
            _settings.ConversionProfiles.Add(secondProfile);
            _settings.ApplicationSettings.LastUsedProfileGuid = secondProfile.Guid;

            _profileSettingsViewModel = CreateProfileSettingsViewModel(_settings);

            Assert.IsTrue(_profileSettingsViewModel.DeleteProfileCommand.CanExecute(null),
                          "Can Execute is not enabled for profile with enabled deletable property.");
        }
Пример #24
0
        public ActionResult ProfileSettings()
        {
            var db   = new ApplicationDbContext();
            var user = db.Users.FirstOrDefault(c => c.UserName == User.Identity.Name);
            ProfileSettingsViewModel model = new ProfileSettingsViewModel();

            model.UserName    = user.UserName;
            model.PhoneNumber = user.Mobile;
            model.Email       = user.Email;
            model.Address     = user.Address;
            model.NickName    = user.Nickname;
            return(View(model));
        }
        public void AddProfile_QueryProfileNameReturnsNull_AddingGetsCanceled()
        {
            _profileSettingsViewModel = CreateProfileSettingsViewModel(_settings);

            var formerCurrentProfile = _profileSettingsViewModel.CurrentProfile;

            _interactionInvoker.HandleInputInteraction = interaction => { interaction.Success = false; };

            _profileSettingsViewModel.AddProfileCommand.Execute(null);

            Assert.AreEqual(1, _profileSettingsViewModel.Settings.ConversionProfiles.Count,
                            "Wrong number of profiles after canceled adding");
            Assert.AreEqual(formerCurrentProfile, _profileSettingsViewModel.CurrentProfile,
                            "Current profile is not the former current profile before canceled adding");
        }
        private ProfileSettingsViewModel CreateProfileSettingsViewModel(PdfCreatorSettings settings)
        {
            var interactionInvoker = Substitute.For <IInteractionInvoker>();
            var viewModelBundle    = BuildViewModelBundle(interactionInvoker);

            _profileChecker = Substitute.For <IProfileChecker>();
            _profileChecker.ProfileCheckDict(Arg.Any <IList <ConversionProfile> >(), Arg.Any <Accounts>()).Returns(new ActionResultDict());
            var viewModel = new ProfileSettingsViewModel(_interactionInvoker, new ProfileSettingsWindowTranslation(), _profileChecker, viewModelBundle);

            var interaction = new ProfileSettingsInteraction(settings, new GpoSettingsDefaults());

            _interactionHelper = new InteractionHelper <ProfileSettingsInteraction>(viewModel, interaction);

            return(viewModel);
        }
        public IActionResult Ayarlar(ProfileSettingsViewModel model)
        {
            var entity = new Seller()
            {
                SellerId       = model.SellerId,
                NameAndSurname = model.SellerName,
                City           = model.City,
                Adress         = model.Adress,
                EmailAdress    = model.Email,
                PhoneNumber    = model.PhoneNumber
            };

            _sellerService.Update(entity);
            TempData.Add("message", String.Format("Profil bilgileriniz başarıyla güncellendi!"));
            return(View(model));
        }
        public IActionResult Ayarlar(ProfileSettingsViewModel model)
        {
            var entity = new Buyer()
            {
                BuyerId         = model.BuyerId,
                BuyerName       = model.BuyerName,
                Adress          = model.Adress,
                Email           = model.Email,
                PhoneNumber     = model.PhoneNumber,
                ProfileImageUrl = model.ProfileImageUrl
            };

            _buyerService.Update(entity);
            TempData.Add("message", String.Format("Profil bilgileriniz başarıyla güncellendi!"));
            return(View(model));
        }
        public void RenameProfile_QueryProfileNameReturnsNewProfileName()
        {
            _profileSettingsViewModel = CreateProfileSettingsViewModel(_settings);
            _profileSettingsViewModel.CurrentProfile.Properties.Renamable = true;

            _interactionInvoker.HandleInputInteraction = interaction =>
            {
                interaction.Success   = true;
                interaction.InputText = NewProfileName;
            };

            _profileSettingsViewModel.RenameProfileCommand.Execute(null);

            Assert.AreEqual(NewProfileName, _profileSettingsViewModel.CurrentProfile.Name,
                            "Wrong Profile name after renaming");
        }
        public IActionResult Ayarlar()
        {
            var usersAndProfile          = _usersAndSellersService.GetByUserId(_userManager.GetUserId(User));
            var sellerId                 = usersAndProfile.SellerId;
            var seller                   = _sellerService.GetById(sellerId);
            var profileSettingsViewModel = new ProfileSettingsViewModel
            {
                SellerId    = seller.SellerId,
                SellerName  = seller.NameAndSurname,
                City        = seller.City,
                Adress      = seller.Adress,
                Email       = seller.EmailAdress,
                PhoneNumber = seller.PhoneNumber
            };

            return(View(profileSettingsViewModel));
        }