Exemplo n.º 1
0
        public ActionResult UserPage(UserPageViewModel model, long?id)
        {
            if (!ModelState.IsValid)
            {
                return(View());
            }
            var user = _userManager.GetById((long)id);

            model = Mapper.Map <User, UserPageViewModel>(user);

            int coutOrder = 0;
            List <OrderViewModel> orders = new List <OrderViewModel>();
            IQueryable <Order>    ordersList;

            ordersList = _orderManager.GetOrdersByUserId(user.id).OrderByDescending(x => x.dateOrder);

            foreach (var order in ordersList)
            {
                orders.Add(Mapper.Map <Order, OrderViewModel>(order));
                if (coutOrder == 2)
                {
                    break;
                }
                coutOrder++;
            }
            model.LastUserOrders = orders;

            return(View(model));
        }
Exemplo n.º 2
0
        public async Task <ActionResult> User(string userName)
        {
            User user = _userManager.GetByUserName(userName);

            if (user == null)
            {
                return(HttpNotFound());
            }
            List <IntegrationInfo> integrationInfos = await GetUserIntegrationInfo(user);


            var viewModel = new UserPageViewModel
            {
                User = user,
                UserIntegrationInfos = integrationInfos,
                AverageRating        = _userRatingManger.GetAverageRating(user.ID),
                IsUserLoggedIn       = IsUserLoggedIn(),
                HasLoggedInUserRated = HasLoggedInUserRated(user.ID),
                IsUserFollowing      = IsUserFollowedToUser(user.ID)
            };

            try
            {
                viewModel.RecentContent = await _videoContentGetter.GetRecentVideos(user.ID, 7);
            }
            catch (Exception)
            {
                ViewBag.Message = "An error occured when loading recent content.";
            }

            return(View(nameof(User), viewModel));
        }
        public ActionResult UserDetails(string username, int page = 1, int count = 3)
        {
            var user = this.Data.Users.All()
                       .FirstOrDefault(u => u.UserName == username);

            if (user == null)
            {
                return(this.HttpNotFound("Incorrect username - user is not found"));
            }

            var snippets = this.Data.Snippets.All()
                           .Include(s => s.Author)
                           .Where(s => s.Author.UserName == username)
                           .OrderByDescending(s => s.CreationTime)
                           .ThenByDescending(s => s.Id)
                           .Skip((page - 1) * count)
                           .Take(count);

            int snippetsCount = user.Snippets.Count();

            this.ViewBag.TotalPages  = (snippetsCount + count - 1) / count;
            this.ViewBag.CurrentPage = page;
            var model = new UserPageViewModel()
            {
                UserDetails  = Mapper.Map <UserDetailsViewModel>(user),
                UserSnippets = Mapper.Map <IEnumerable <UserSnippetViewModel> >(snippets)
            };

            return(this.View(model));
        }
Exemplo n.º 4
0
        public ActionResult UserPage(string slug)
        {
            UserPageViewModel model = new UserPageViewModel();
            var pages       = GetPages();
            var pageid      = _pageRepository.GetPagesIdBySlug(slug);
            var page        = _pageRepository.GetPageById(pageid);
            var Images      = GetPageImages(page);
            var firstPageId = pages.OrderBy(i => i.PostedOn).First().Id;
            var lastPageId  = pages.OrderBy(i => i.PostedOn).Last().Id;
            var nextId      = pages.OrderBy(i => i.PostedOn).SkipWhile(i => i.Id != pageid).Skip(1).Select(i => i.Id).FirstOrDefault();
            var previousId  = pages.OrderBy(i => i.PostedOn).TakeWhile(i => i.Id != pageid).Select(i => i.Id).LastOrDefault();

            model.FirstPageId      = firstPageId;
            model.LastPageId       = lastPageId;
            model.PreviousPageSlug = pages.Where(x => x.Id == previousId).Select(x => x.UrlSeo).FirstOrDefault();
            model.NextPageSlug     = pages.Where(x => x.Id == nextId).Select(x => x.UrlSeo).FirstOrDefault();
            model.ID          = page.Id;
            model.PageCount   = pages.Count();
            model.UrlSeo      = page.UrlSeo;
            model.Images      = Images;
            model.UserName    = page.UserName;
            model.UserImage   = page.UserImage;
            model.City        = page.City;
            model.Body        = page.Body;
            model.Exp         = page.Exp;
            model.Email       = page.Email;
            model.Address     = page.Address;
            model.PhoneNumber = page.PhoneNumber;


            return(View(model));
        }
Exemplo n.º 5
0
        public async Task <ActionResult> Update(UserPageViewModel model)
        {
            var userContext = _userContextAccessor.GetContext();
            var userId      = userContext.UserId;

            if (ModelState.IsValid)
            {
                var page = model.ProjectTo <Page>();

                if (page.Id != null)
                {
                    await _pageManager.UpdateAsync(page);
                }
                else
                {
                    await _pageManager.CreateAsync(page, userId);

                    model.Id = page.Id;
                }

                return(Ok(model));
            }

            return(BadRequest(ModelState));
        }
Exemplo n.º 6
0
 public UserPage()
 {
     InitializeComponent();
     vm = new UserPageViewModel(this);
     this.DataContext = vm;
     this.BindElements();
 }
Exemplo n.º 7
0
 public UserPage()
 {
     context             = new UserPageViewModel();
     context.Push       += (p) => Navigation.PushAsync(p);
     this.BindingContext = context;
     InitializeComponent();
 }
Exemplo n.º 8
0
        public ActionResult Users(int pageNumber = 1)
        {
            UserPageViewModel model = new UserPageViewModel();

            model.Users      = new List <UsersViewModel>();
            model.MaxPages   = _repo.MaxUserPages();
            model.PageNumber = pageNumber;

            var users = _repo.GetUsersByPage(pageNumber);
            var roles = _repo.GetUserRoles();

            foreach (var user in users)
            {
                var userToAdd = new UsersViewModel
                {
                    FirstName = user.FirstName,
                    LastName  = user.LastName,
                    UserName  = user.UserName,
                    UserRole  = roles.Single(r => r.Id == user.Roles.First().RoleId).Name
                };
                model.Users.Add(userToAdd);
            }

            return(View(model));
        }
Exemplo n.º 9
0
        // Returns a user's profile
        public async Task <IActionResult> Index(int id, int page = 1)
        {
            // Retrieves users and return 404 if null
            User user = await _repository.GetUserAsync(id);

            if (user == null)
            {
                return(NotFound());
            }

            // Retrieves comments and logged in user
            IEnumerable <UserComment> userComments = _repository.GetUserComments(user, page);
            User currentUser = await _repository.GetUserAsync(User);

            // Creates model and returns view
            UserPageViewModel model = new UserPageViewModel()
            {
                User                = user,
                Page                = page,
                PageCount           = (user.UserPageComments.Count(x => !x.Deleted) + (CommentsPerPage - 1)) / CommentsPerPage,
                CurrentUser         = currentUser,
                CurrentPageComments = userComments
            };

            return(View("User", model));
        }
Exemplo n.º 10
0
 public UserPage()
 {
     if (WpfUtil.IsInDesignMode)
     {
         return;
     }
     this.Vm          = new UserPageViewModel();
     this.DataContext = this.Vm;
     InitializeComponent();
     this.OnLoaded(window => {
         window.AddEventPath <Per20SecondEvent>("外网群控用户列表页面打开着时周期刷新", LogEnum.DevConsole, action: message => {
             Vm.Refresh();
         }, this.GetType());
         window.AddEventPath <UserEnabledEvent>("外网群控用户列表页面打开着时,用户启用后刷新Vm内存", LogEnum.DevConsole, action: message => {
             UIThread.Execute(() => {
                 var userVm = Vm.QueryResults.FirstOrDefault(a => a.LoginName == message.Source.LoginName);
                 if (userVm != null)
                 {
                     userVm.IsEnabled = true;
                 }
             });
         }, this.GetType());
         window.AddEventPath <UserDisabledEvent>("外网群控用户列表页面打开着时,用户禁用后刷新Vm内存", LogEnum.DevConsole, action: message => {
             UIThread.Execute(() => {
                 var userVm = Vm.QueryResults.FirstOrDefault(a => a.LoginName == message.Source.LoginName);
                 if (userVm != null)
                 {
                     userVm.IsEnabled = false;
                 }
             });
         }, this.GetType());
     });
 }
Exemplo n.º 11
0
        public async Task <UserPageViewModel> GetPageCreateViewModel(string parentId)
        {
            var pageIds = await GetUserManagedPageIds();

            if (!pageIds.Contains(parentId))
            {
                throw new UnauthorizedAccessException($"User not unauthorized to create under Page: {parentId}");
            }

            var parentPage = await _pageManager.GetByIdAsync(parentId);

            var siteId = parentPage.SiteId;

            var model = new UserPageViewModel()
            {
                Id           = null,
                SiteId       = parentPage.SiteId,
                ParentPageId = parentPage.Id,
                PageMasterId = parentPage.PageMasterId,
                Path         = parentPage.Path
            };

            model.Path         += model.Path.EndsWith("/") ? "child" : "/child";
            model.DefaultDomain = await _pageManager.GetDefaultDomain(siteId);

            model.MasterPages = await GetMasterPagesSelectList(siteId);

            return(model);
        }
Exemplo n.º 12
0
        public UpdateViewToEditNoteViewCommand(UserPageViewModel userPageViewModel, MainWindowViewModel viewModel)
        {
            _userPageViewModel   = userPageViewModel;
            _mainWindowViewModel = viewModel;

            _userPageViewModel.PropertyChanged += UserPageViewModel_PropertyChanged;
        }
Exemplo n.º 13
0
 public UserPageViewModelTest()
 {
     _mockNavigationService       = new Mock <INavigationService>();
     _mockAuthentificationService = new Mock <IAuthentificationService>();
     _mockPageDialogService       = new Mock <IPageDialogService>();
     _userPageViewModel           = new UserPageViewModel(_mockNavigationService.Object, _mockAuthentificationService.Object, _mockPageDialogService.Object);
 }
Exemplo n.º 14
0
        public async Task <IActionResult> Profile(Guid userId, int page)
        {
            if (userId == this.UserId)
            {
                return(this.RedirectToAction("MyPage"));
            }

            var posts = await this.postsRepository.GetPosts(userId, this.NormalizePage(page), PageSize);

            var socialStats = await this.subscriptionsRepository.GetSocialStats(this.UserId);

            var user = await this.usersRepository.GetUser(userId);

            user.CanSubscribe = !await this.subscriptionsRepository.IsFollowing(this.UserId, userId);

            var viewModels = new UserPageViewModel
            {
                User      = user,
                Posts     = posts,
                Followers = socialStats.Followers,
                Following = socialStats.Following
            };

            return(this.View("UserPage", viewModels));
        }
Exemplo n.º 15
0
        public HomePage()
        {
            _userPageViewModel = new UserPageViewModel();

            this.InitializeComponent();
            this.DataContext         = _userPageViewModel;
            this.NavigationCacheMode = NavigationCacheMode.Required;
            NavPane.InitializeDrawerLayout();
            Windows.UI.ViewManagement.StatusBar.GetForCurrentView().BackgroundColor = Color.FromArgb(1, 78, 101, 135);

            resourceLoader = new ResourceLoader();

            //TMP MOCKED MENU
            List <string> menuItemsTop = new List <string> {
                ResourceLoader.GetForCurrentView().GetString("Home"), ResourceLoader.GetForCurrentView().GetString("Followers")
            };

            MenuItems.ItemsSource = menuItemsTop;

            List <string> menuItemsBottom = new List <string> {
                ResourceLoader.GetForCurrentView().GetString("Settings"), ResourceLoader.GetForCurrentView().GetString("Login")
            };

            MenuItemsBottom.ItemsSource = menuItemsBottom;
        }
Exemplo n.º 16
0
        // GET: /Account/UserPage
        public ActionResult UserPage(ManageMessageId?message)
        {
            ViewBag.StatusMessage =
                message == ManageMessageId.ChangePasswordSuccess ? "Ваш пароль изменен."
                : message == ManageMessageId.SetPasswordSuccess ? "Ваш пароль установлен."
                : message == ManageMessageId.Error ? "Произошла ошибка."
                : message == ManageMessageId.TariffAddedSuccess ? "Тариф успешно добавлен"
                 : message == ManageMessageId.TariffRemovedSuccess ? "Тариф успешно удален"
                 : message == ManageMessageId.PaymentSuccess ? "Оплата успешно произведена"
                : "";

            var userId  = User.Identity.GetUserId();
            var account = _accountService.GetUserAccount(userId);
            var model   = new UserPageViewModel
            {
                HasPassword = HasPassword(),
                Balance     = account.Balance,
                Fee         = account.Tariffs.Count > 0?account.Tariffs.Sum(x => x.Tariff.Price):0,
                PaymentDate = account.Tariffs.Count > 0 ? account.Tariffs.Min(x => x.EndDate):DateTime.Now,
                Tariffs     = new List <Tuple <string, string> >()
            };

            foreach (var item in account.Tariffs)
            {
                model.Tariffs.Add(new Tuple <string, string>(item.Tariff.Id.ToString(), item.Tariff.TariffName));
            }
            return(View(model));
        }
Exemplo n.º 17
0
 public UsersPage()
 {
     InitializeComponent();
     viewModel   = new UserPageViewModel();
     DataContext = viewModel;
     usersPage   = this;
 }
Exemplo n.º 18
0
        // GET: Userpage
        public ActionResult Index()
        {
            var userId = User.Identity.GetUserId();


            UserPageViewModel Page = new UserPageViewModel();

            Page.User = db.Users
                        .Where(c => c.Id == userId)
                        .Select(c => c).First();


            Guid id = Guid.Parse(userId);

            var news = (from sub in db.Subscriptions
                        join p in db.Posts on sub.CommunityId equals p.CommunityId
                        join c in db.Communities on sub.CommunityId equals c.CommunityId
                        join r in db.Editors on p.RightsId equals r.EditorRightsId
                        join u in db.Users on r.UserId.ToString() equals u.Id
                        where sub.SubscriptionCancelationDate == null &&
                        sub.UserId == id
                        orderby p.CreationDate descending
                        select new
            {
                p.PostId,
                p.CreationDate,
                p.Text,
                sub.CommunityId,
                c.Name,
                u.LastName,
                u.FirstName,
                u.Id
            }).ToList();


            Page.News = new List <PostInfo>();

            foreach (var item in news)
            {
                PostInfo one = new PostInfo {
                    PostId = item.PostId, AuthorFN = item.FirstName, AuthorLN = item.LastName, CommunityId = item.CommunityId, CommunityName = item.Name, CreationDate = item.CreationDate, Text = item.Text, AuthorId = Guid.Parse(item.Id)
                };
                Page.News.Add(one);
            }

            string filePath = Server.MapPath(Url.Content("~/Temp/" + userId + ".jpeg"));

            if (System.IO.File.Exists(filePath))
            {
                ViewBag.hasPicture = true;
            }
            else
            {
                ViewBag.hasPicture = false;
            }


            return(View(Page));
        }
Exemplo n.º 19
0
        public ActionResult UserPage(string Id)
        {
            var appUser = this.Data.Users.GetById(Id);

            UserPageViewModel vm = CreateUserViewModel(appUser);

            return(View(vm));
        }
Exemplo n.º 20
0
        public ActionResult AddImageToPage(string pageid, string slug)
        {
            UserPageViewModel model = new UserPageViewModel();

            model.ID     = pageid;
            model.UrlSeo = slug;
            return(View(model));
        }
Exemplo n.º 21
0
        public ActionResult Index()
        {
            UserPageViewModel model = new UserPageViewModel();

            model.VisitedBoards = AccountQueries.GetLastVisitedBoards(User.Identity.Name);
            model.MyBoards      = AccountQueries.GetMyBoards(User.Identity.Name);
            return(View(model));
        }
Exemplo n.º 22
0
        public UserPage()
        {
            InitializeComponent();

            UserPageViewModel vm = new UserPageViewModel();

            BindingContext = vm;
        }
Exemplo n.º 23
0
        public override UserPageViewModel ToViewModel(ICollection <User> model)
        {
            var viewModel = new UserPageViewModel
            {
                Users = userViewModelMapper.ToViewModels(model)
            };

            return(viewModel);
        }
Exemplo n.º 24
0
        public async Task <IActionResult> MyPage()
        {
            var model = new UserPageViewModel()
            {
                User = await _userService.GetByLoginAsync(User.Identity.Name)
            };

            model.Posts = (await _postService.GetAsync());
            return(View(model));
        }
Exemplo n.º 25
0
        public IActionResult EditThisUserDoctorsAppointments(UserPageViewModel viewModel)
        {
            var enrolledCitizen = receptionRepository.Get(viewModel.EnrolledCitizenId);
            var appointment     = mapper.Map <ReceptionOfPatients>(viewModel);

            appointment.EnrolledCitizen = enrolledCitizen.EnrolledCitizen;
            receptionRepository.Save(appointment);

            return(RedirectToAction("UserPage"));
        }
Exemplo n.º 26
0
        public UserPage(Usuario usuario)
        {
            InitializeComponent();

            viewModel = new UserPageViewModel(usuario);

            BindingContext = viewModel;

            btnCambiarUsuario.Clicked += BtnCambiarUsuario_Clicked;
        }
Exemplo n.º 27
0
        public IActionResult UserPage()
        {
            var user  = _userService.GetUser(User.FindFirstValue(ClaimsIdentity.DefaultIssuer));
            var model = new UserPageViewModel();

            model.AnsPercent = _testService.GetCorrectAnsPercent(user);
            model.UserName   = user.Name;
            model.UserTests  = _testService.GetUserTests(user);
            return(View(model));
        }
Exemplo n.º 28
0
        public async Task <IActionResult> Index(Guid id)
        {
            var user = await users.Get(id);

            var page = new UserPageViewModel
            {
                User = user
            };

            return(View(page));
        }
Exemplo n.º 29
0
        private static UserPageViewModel CreateUserViewModel(ApplicationUser appUser)
        {
            UserPageViewModel vm = new UserPageViewModel()
            {
                Username = appUser.UserName,
                Tweets   = appUser.Tweets.OrderByDescending(x => x.DateCreated).ToList(),
                Tweet    = new Tweet()
            };

            return(vm);
        }
Exemplo n.º 30
0
 public ActionResult Create(UserPageViewModel page)
 {
     if (page != null)
     {
         var currentUserId = User.Identity.GetUserId();
         page.UserId = currentUserId;
         var pageDto = Mapper.Map <UserPageDTO>(page);
         pageService.Create(pageDto);
     }
     return(RedirectToAction("Index", "Page"));
 }
Exemplo n.º 31
0
 public ActionResult Register()
 {
     var userPageViewModel = new UserPageViewModel();
     return this.View(userPageViewModel);
 }
Exemplo n.º 32
0
        public ActionResult Register(UserPageViewModel userPageViewModel)
        {
            var userSaveDetails = this.userSaveDetailsMapper.MapFrom(userPageViewModel.Form);

            try
            {
                this.userTasks.Save(userSaveDetails);
                this.userTasks.SignOn(userSaveDetails);
            }
            catch (RulesException exception)
            {
                exception.AddModelStateErrors(this.ModelState, "form");
                return this.View(userPageViewModel);
            }

            return this.RedirectToAction("index", "blog");
        }