public void RemoveItemFromBasket_ShouldRedirectToProfilePage() { // Arrange var userId = "12345"; var itemId = 11; var order = new Order(); var orderVm = new OrderViewModel(); var previousOrders = new List <Order>(); this.identityProviderMock.Setup(i => i.GetUserId()).Returns(userId); this.orderServiceMock.Setup(o => o.GetOrderInBasket(userId)).Returns(order); this.mappingServiceMock.Setup(m => m.Map <Order, OrderViewModel>(order)); this.orderServiceMock.Setup(o => o.PreviousOrders(userId)).Returns(previousOrders); var model = new ProfilePageViewModel(); var profileController = new ProfileController(this.orderServiceMock.Object, this.mappingServiceMock.Object, this.imageProviderMock.Object, this.identityProviderMock.Object); // Act var redirectResult = profileController.RemoveItemFromBasket(orderVm, itemId) as RedirectResult; // Assert Assert.IsNotNull(redirectResult); Assert.AreEqual(ServerConstants.ProfilePageRedirectUrl, redirectResult.Url); }
public ActionResult UserProfile(string id) { var user = this.users.ById(id); if (user == null) { return(this.View("Error")); } var profileInfo = this.Mapper.Map <PublicProfileDetailed>(user); var lastQuizzes = this.Mapper.Map <List <CreatedQuizInfo> >( user.QuizzesCreated.OrderByDescending(q => q.CreatedOn).Take(5)); var lastSolutions = this.Mapper.Map <List <TakenQuizInfo> >( user.SolutionsSubmited.OrderByDescending(s => s.CreatedOn).Take(5)); var pageModel = new ProfilePageViewModel { PublicProfile = profileInfo, QuizzesCreated = lastQuizzes, QuizzesTaken = lastSolutions }; var maxQuizzesCreated = this.users.GetMaxCreatedQuizzesCount(); PublicProfileDetailed.MaxQuizzesCreated = maxQuizzesCreated; return(this.View(pageModel)); }
public ProfilePageView() { this.InitializeComponent(); viewModel = new ProfilePageViewModel(); this.DataContext = viewModel; this.NavigationCacheMode = NavigationCacheMode.Required; }
public ActionResult UserProfile(string id) { var user = this.users.ById(id); if (user == null) { return this.View("Error"); } var profileInfo = this.Mapper.Map<PublicProfileDetailed>(user); var lastQuizzes = this.Mapper.Map<List<CreatedQuizInfo>>( user.QuizzesCreated.OrderByDescending(q => q.CreatedOn).Take(5)); var lastSolutions = this.Mapper.Map<List<TakenQuizInfo>>( user.SolutionsSubmited.OrderByDescending(s => s.CreatedOn).Take(5)); var pageModel = new ProfilePageViewModel { PublicProfile = profileInfo, QuizzesCreated = lastQuizzes, QuizzesTaken = lastSolutions }; var maxQuizzesCreated = this.users.GetMaxCreatedQuizzesCount(); PublicProfileDetailed.MaxQuizzesCreated = maxQuizzesCreated; return this.View(pageModel); }
private void OpenProfilePage(object sender, ProfilePageViewModel viewModel) { var page = new ProfilePage(viewModel); NavigationPage.SetHasBackButton(page, true); MainPage.Navigation.PushAsync(page); }
public async Task ProfilePage_ShouldCheckIfTheProfileHasBeenLoaded_Pass() { //Arrange var keychainService = container.Resolve <IKeychainService>(); var navigationService = container.Resolve <INavigationService>(); var authenticationFacade = container.Resolve <IAuthenticationFacade>(); var dialogService = container.Resolve <IPageDialogService>(); var accountFacade = container.Resolve <IAccountFacade>(); var keychain = SetupHelper.CreateFakeKeyChain(this.container); var ProfilePageViewModel = new ProfilePageViewModel(dialogService, authenticationFacade, accountFacade, keychain, navigationService); //Act ProfilePageViewModel.OnNavigatedTo(new NavigationParameters()); // call account facade to get Profile Details. var myProfile = await accountFacade.MyProfile(keychainService.GetAuthorizedKeychainRequestModel()); var profile = myProfile?.Content?.MyProfile; await Task.Delay(2000); //Assert Assert.Equal(ProfilePageViewModel.Email, profile.EmailAddress); Assert.Equal(ProfilePageViewModel.FirstName, profile.FirstName); Assert.Equal(ProfilePageViewModel.LastName, profile.LastName); //Assert.Equal(ProfilePageViewModel, "*****@*****.**"); }
public ActionResult Index(string searchString) { var splitted = searchString.Split(' '); string firstName = splitted[0]; string lastName = splitted[1]; Debug.WriteLine("FirstNAME " + firstName); Debug.WriteLine("LastName " + lastName); var tempID = db.Users.Where(u => u.FirstName.Equals(firstName) && u.LastName.Equals(lastName)) .Select(u => new { ID = u.ID }).Single(); var userID = tempID.ID; var user = from a in db.Users select a; user = user.Where(a => a.ID.Equals(userID)); var newsfeed = from s in db.NewsFeed select s; newsfeed = newsfeed.Where(s => s.UserID.Equals(userID)); ProfilePageViewModel profilePageViewModel = new ProfilePageViewModel(); profilePageViewModel.NewsFeed = newsfeed; profilePageViewModel.User = user; return(View(profilePageViewModel)); }
public ProfilePage() { InitializeComponent(); ProfilePageViewModel profilePageViewModel = new ProfilePageViewModel(); BindingContext = profilePageViewModel; NavigationPage.SetHasNavigationBar(this, false); var myCarousel = new CarouselViewControl(); myCarousel.ItemsSource = new ObservableRangeCollection <View> { new FavoritesView(), new CreditInformationView(), new FriendsView() }; myCarousel.ShowIndicators = true; myCarousel.IndicatorsShape = IndicatorsShape.Circle; //myCarousel.ItemTemplate = new MyTemplateSelector(); //new DataTemplate (typeof(MyView)); myCarousel.BackgroundColor = Color.White; myCarousel.Position = 0; //default //myCarousel.InterPageSpacing = 10; myCarousel.Orientation = CarouselViewOrientation.Horizontal; Frame carouselFrame = new Frame() { Content = myCarousel, CornerRadius = 10, Padding = 0, Margin = 0, }; ProfilePageGrid.Children.Add(carouselFrame, 0, 3); Grid.SetColumnSpan(carouselFrame, 2); }
public void ProfilePage_ShouldCallAllNeededServicesToLoadProfilePage() { // Arrange var userId = "12345"; var order = new Order(); var orderVm = new OrderViewModel(); var previousOrders = new List <Order>(); this.identityProviderMock.Setup(i => i.GetUserId()).Returns(userId); this.orderServiceMock.Setup(o => o.GetOrderInBasket(userId)).Returns(order); this.mappingServiceMock.Setup(m => m.Map <Order, OrderViewModel>(order)); this.orderServiceMock.Setup(o => o.PreviousOrders(userId)).Returns(previousOrders); var model = new ProfilePageViewModel(); var profileController = new ProfileController(this.orderServiceMock.Object, this.mappingServiceMock.Object, this.imageProviderMock.Object, this.identityProviderMock.Object); // Act profileController.ProfilePage(model); // Assert this.identityProviderMock.Verify(i => i.GetUserId(), Times.Once); this.orderServiceMock.Verify(o => o.GetOrderInBasket(userId), Times.Once); this.mappingServiceMock.Verify(m => m.Map <Order, OrderViewModel>(order), Times.Once); this.orderServiceMock.Verify(o => o.PreviousOrders(userId), Times.Once); }
public ActionResult Index(ProfilePage currentPage) { var viewModel = new ProfilePageViewModel { CurrentPage = currentPage }; return(View(viewModel)); }
public ProfilePage() { InitializeComponent(); BindingContext = new ProfilePageViewModel { Navigation = Navigation }; }
private async void Initialize() { var viewmodel = new ProfilePageViewModel(); // await your data to load await viewmodel.GetProfileAsync(); BindingContext = viewmodel; }
public ActionResult ProfilePage(int id = -1) { var model = new ProfilePageViewModel { ProfileUser = UnitOfWork.Users.GetUserWithPicture(id), LoggedInUser = UnitOfWork.Users.GetUserWithPicture(LoggedInUserId), AllFriendships = UnitOfWork.Friendships.GetAllFriendships(LoggedInUserId) }; return(View(model)); }
public ActionResult ShowInfo() { var ctx = new OruBloggenDbContext(); var identityCtx = new ApplicationDbContext(); var userId = User.Identity.GetUserId(); var Users = ctx.Users.Find(userId); var identityUser = identityCtx.Users.Find(userId); var teamId = Users.UserTeamID; var team = ctx.Teams.FirstOrDefault(t => t.TeamID == teamId).TeamName; var path = "/Images/" + Users.UserImagePath; var creator = ctx.Meetings.Where(m => m.MeetingUserID.Equals(userId)).ToList(); var invited = ctx.UserMeetings.Where(u => u.UserID.Equals(userId)).Where(u => u.AcceptedInvite == false).ToList(); var accepted = ctx.UserMeetings.Where(u => u.UserID.Equals(userId)).Where(u => u.AcceptedInvite == true).ToList(); foreach (var accept in accepted) { var meeting = ctx.Meetings.FirstOrDefault(m => m.MeetingID == accept.MeetingID); creator.Add(meeting); } creator = creator.OrderBy(u => u.MeetingStartDate).ToList(); creator = creator.Where(u => u.MeetingStartDate >= DateTime.Now).ToList(); invited = invited.Where(u => u.MeetingModel.MeetingUserID != u.UserID).ToList(); var notmodel = ctx.Notifications.Where(t => t.UserID == userId).ToList(); var ListOfCategories = ctx.Categories.ToList(); var model = new ProfilePageViewModel { userId = userId, OtherUserID = userId, ImagePath = path, Firstname = Users.UserFirstname, Lastname = Users.UserLastname, Email = identityUser.Email, PhoneNumber = Users.UserPhoneNumber, Team = team, Position = Users.UserPosition, MeetingModels = creator, UserMeetings = invited, UserEmailNotification = Users.UserEmailNotification, UserPmNotification = Users.UserPmNotification, UserSmsNotification = Users.UserSmsNotification, ListCategories = ListOfCategories, IsFollowed = notmodel, }; return(View(model)); }
public ViewResult Save(ProfilePage currentPage) { //model2.Profile.Save(); var model = new ProfilePageViewModel(currentPage) { Profile = EPiServerProfile.Current, //Impersonating = false }; return(View("~/Views/ProfilePage/Index.cshtml", model)); }
public Profile(User user) : this() { BindingContext = new ProfilePageViewModel(user); _viewModel.LoadingStartedEvent += (sender, e) => { loading_view.IsVisible = true; }; _viewModel.LoadingEndedEvent += (sender, e) => { Make_User_Editable(); loading_view.IsVisible = false; }; if (string.IsNullOrWhiteSpace(entry_name.Text) && string.IsNullOrWhiteSpace(entry_lastname.Text) && string.IsNullOrWhiteSpace(entry_mail.Text)) { Make_User_Editable(); } }
public ProfilePage() { InitializeComponent(); Title = "Profile"; BindingContext = profilePageViewModel = new ProfilePageViewModel(); /** * if(profilePageViewModel.User == null) * { * profilePageViewModel.LoadMyProfile.Execute(null); * } */ }
public ProfilePage() { InitializeComponent(); //this.BackgroundColor = Color.FromRgb(0, 200, 255); this.BackgroundColor = Color.White; service = new NotificationService(); var viewModel = new ProfilePageViewModel(); this.BindingContext = viewModel; }
public ActionResult ProfilePage(ProfilePageViewModel model) { var userId = this.identityProvider.GetUserId(); var dbOrderInBasket = this.orderService.GetOrderInBasket(userId); var mvOrderInBasket = this.mappingService.Map <Order, OrderViewModel>(dbOrderInBasket); model.OrderInBasket = mvOrderInBasket; var dbPreviousOrders = this.orderService.PreviousOrders(userId); model.PreviousOrders = this.ConvertToOrderViewModelList(dbPreviousOrders); return(View(model)); }
public async Task <IActionResult> Index(Models.ProfilePage currentPage) { var viewModel = new ProfilePageViewModel(currentPage) { Orders = GetOrderHistoryViewModels(), Addresses = GetAddressViewModels(), SiteUser = await CustomerService.GetSiteUserAsync(User.Identity.Name), CustomerContact = new FoundationContact(CustomerService.GetCurrentContact().Contact), OrderDetailsPageUrl = UrlResolver.Current.GetUrl(_settingsService.GetSiteSettings <ReferencePageSettings>()?.OrderDetailsPage ?? ContentReference.StartPage), ResetPasswordPage = UrlResolver.Current.GetUrl(_settingsService.GetSiteSettings <ReferencePageSettings>()?.ResetPasswordPage ?? ContentReference.StartPage), AddressBookPage = UrlResolver.Current.GetUrl(_settingsService.GetSiteSettings <ReferencePageSettings>()?.AddressBookPage ?? ContentReference.StartPage) }; return(View(viewModel)); }
private object GetProfile(object arg) { var user = this.CurrentWchmUser(); var profile = this.documentSession.Load <User>(user.Id); var assertions = profile.Assertions.Select(Mapper.Map <Assertion, ProfileAssertionViewModel>).ToArray(); var model = new ProfilePageViewModel { Name = profile.GetName(), Assertions = assertions }; return(this.View["Profile", model]); }
public ProfilePage(User user) { InitializeComponent(); _user = user; BindingContext = viewModel = new ProfilePageViewModel(_user); ChangePhonePopup.Body.BindingContext = viewModel; Init(); ChangePasswordPopup.BackgroundColor = Color.FromRgba(0, 0, 0, 0.3); ChangeEmailPopup.BackgroundColor = Color.FromRgba(0, 0, 0, 0.3); ChangePhonePopup.BackgroundColor = Color.FromRgba(0, 0, 0, 0.3); OtpPopup.BackgroundColor = Color.FromRgba(0, 0, 0, 0.3); MessagingCenter.Subscribe <ProfilePageViewModel, bool>(this, "OtpPopup", async(sender, arg) => { OtpPopup.IsVisible = arg; entryOTP1.Focus(); progressBar.Progress = 1; spReset.TextColor = Color.Gray; Device.StartTimer(TimeSpan.FromMilliseconds(updateRate), () => { if (progressBar.Progress > 0) { Device.BeginInvokeOnMainThread(() => progressBar.Progress -= step); return(true); } lblResetOtp.IsEnabled = true; spReset.TextColor = Color.FromHex("0089D1"); return(false); }); }); MessagingCenter.Subscribe <ProfilePageViewModel, User>(this, "UpdateProfile", async(sender, arg) => { viewModel.User = arg; image.Source = arg.AvatarFullUrl; }); MessagingCenter.Subscribe <ProfilePageViewModel, bool>(this, "ClosePopup", async(sender, arg) => { ChangePasswordPopup.IsVisible = ChangePhonePopup.IsVisible = ChangeEmailPopup.IsVisible = arg; }); ChangePasswordPopup.CustomCloseButton(OnCloseChangePassword); ChangeEmailPopup.CustomCloseButton(OnCloseChangeEmail); ChangePhonePopup.CustomCloseButton(OnCloseChangePhone); }
public ProfilePage() { InitializeComponent(); if (Device.RuntimePlatform == Device.Android) { NavigationPage.SetHasBackButton(this, false); } this.BackgroundColor = Color.White; service = new NotificationService(); var viewModel = new ProfilePageViewModel(); this.BindingContext = viewModel; }
public async Task Test1_LoadMyProfile() { //Arrange //Init the user string uid = "6H7I6z5BsDcyU1xP53DG2CAHOj53"; var user = await UsersFirestore.GetUserByUIDAsync(uid); UsersFirestore.myProfile = user; var vm = new ProfilePageViewModel(); //Act vm.LoadMyProfile.Execute(null); //Assert Assert.True(vm.User.name.Equals("Fiora")); }
public ActionResult PostProfile(int id, ProfilePageViewModel post, HttpPostedFileBase[] UploadedFile) { var currentUserRequesting = db.Users.Where(a => a.Email == User.Identity.Name).FirstOrDefault(); if (SessionManagement.isUserLegitRequest(id, currentUserRequesting.UserId)) { if (ModelState.IsValid) { post.postM.UploadFiles = new List <UploadFile>(); foreach (HttpPostedFileBase file in UploadedFile) { if (file != null && file.ContentLength > 0) { var ToDbFile = new UploadFile { UploadFileType = file.ContentType, Post = post.postM }; using (var reader = new BinaryReader(file.InputStream)) { ToDbFile.UploadContent = reader.ReadBytes(file.ContentLength); } db.UploadFiles.Add(ToDbFile); } } post.postM.DateofPost = DateTime.Now; post.postM.UserId = id; db.Posts.Add(post.postM); db.SaveChanges(); return(RedirectToAction("ProfilePage", "Profile", new { id = id })); } else { ViewBag.Message3 = "Posting Failed"; return(RedirectToAction("ProfilePage", "Profile", new { id = id })); } } else { ViewBag.Message3 = "You are not the current user of this account"; return(RedirectToAction("ProfilePage", "Profile", new { id = id })); } }
public async Task Test2_LoadMyProfile() { //Arrange //Init the user string uid = "ryZJ4v8INRes4o2ZxEaNOPDtqgo2"; var user = await UsersFirestore.GetUserByUIDAsync(uid); UsersFirestore.myProfile = user; var vm = new ProfilePageViewModel(); //Act vm.LoadMyProfile.Execute(null); //Assert Assert.True(vm.User.name.Equals("Volibear")); }
public async Task Test3_LoadMyProfile() { //Arrange //Init the user string uid = "mTwtRUKrzfamBp6PUEMGPMCRNBy1"; var user = await UsersFirestore.GetUserByUIDAsync(uid); UsersFirestore.myProfile = user; var vm = new ProfilePageViewModel(); //Act vm.LoadMyProfile.Execute(null); //Assert Assert.Contains("1fhFeGGSZsIyQqwPkuMA", vm.User.team_leader); }
public ViewResult Index(ProfilePage currentPage) { var model = new ProfilePageViewModel(currentPage) { Profile = EPiServerProfile.Current, //Impersonating = false }; //List<string> users = new List<string>(); //users.Add("Jacob"); //users.Add("Rik"); //users.Add("Dean"); //ViewData["users"] = new SelectList(users); return(View(model)); }
public void ExecuteOrder_ShouldCallOrderService_ExecuteOrder_TimesOnce() { // Arrange var orderId = 11; var totalPrice = 11; this.orderServiceMock.Setup(o => o.ExecuteOrder(orderId, totalPrice)); var model = new ProfilePageViewModel(); var profileController = new ProfileController(this.orderServiceMock.Object, this.mappingServiceMock.Object, this.imageProviderMock.Object, this.identityProviderMock.Object); // Act profileController.ExecuteOrder(orderId, totalPrice); // Assert this.orderServiceMock.Verify(o => o.ExecuteOrder(orderId, totalPrice), Times.Once); }
public ActionResult ProfilePage(int?id) { ViewBag.Message2 = User.Identity.Name; if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Profile profile = db.Profiles.Find(id); ProfilePageViewModel ViewModel = new ProfilePageViewModel { profileM = profile }; if (profile == null) { return(HttpNotFound()); } return(View(ViewModel)); }
public IActionResult SessionUserProfile() { User user = _accountLogic.GetUserById((int)HttpContext.Session.GetInt32("UserId")); ProfilePageViewModel model = new ProfilePageViewModel() { User = new UserViewModel() { Name = user.Name, UserId = user.UserId }, Posts = _postLogic.GetAllPostsByUser(user.UserId).Select(c => new PostViewModel { Title = c.Title, Content = c.Content, PostId = c.PostId, AuraAmount = c.Aura.Amount, PostDate = c.PostDate, UserName = c.User.Name, CategoryName = c.Category.Name }).ToList(), Categories = _categoryLogic.GetAll().Select(c => new CategoryViewModel { Id = c.CategoryId, Name = c.Name }).ToList(), }; return(View(model)); }
private void AddCategoriesTo( ProfilePageViewModel model, IList<Category> categories) { model.Categories = categories.OrderBy(c => c.SortOrder).ToList().MapAllUsing(this.categoryViewModelMapper); }