public IActionResult UserPage()
        {
            UserPageVM userPageVM = new UserPageVM();

            userPageVM.Username = User.Identity.Name;
            return(View(userPageVM));
        }
Example #2
0
        public IActionResult UserPage()
        {
            UserPageVM userPageVM = new UserPageVM();

            userPageVM.Username = User.Identity.Name;

            int userId = GetUserId();

            // hämta usern
            var user = _tvContext
                       .UserToTvTable
                       .Where(x => x.UserId == userId);

            // hämta array av FollowedShowItem
            var followedShowItems = user
                                    .Select(x => new FollowedShowItemVM
            {
                Title = x.TvTable.Title,
                Id    = x.TvTable.TvMazeId,
                // använd apihandler för att sätta bool-proppen is released
                ReleasedToday = ApiHandler.CheckIfAnyEpisodeReleasedToday(x.TvTable.TvMazeId)
            })
                                    .ToArray();

            userPageVM.FollowedShowItems = followedShowItems;

            return(View(userPageVM));
        }
Example #3
0
        public IActionResult Add(WatchlistVM model)
        {
            WatchList watchList = new WatchList();

            watchList.MovieID = model.movieid;
            watchList.UserID  = Convert.ToInt32(TempData["ID"]);

            UserPageVM user = new UserPageVM();

            user.UserWatch = _context.WatchLists.Include(x => x.Movie).Where(q => q.UserID == Convert.ToInt32(TempData["ID"])).ToList().ToPagedList();

            int counter = 0;

            foreach (var item in user.UserWatch)
            {
                if (model.movieid == item.MovieID)
                {
                    counter++;
                }
            }


            if (counter == 0)
            {
                _context.WatchLists.Add(watchList);
                _context.SaveChanges();

                return(Redirect("/watchlist"));
            }

            return(Redirect("/watchlist"));
        }
Example #4
0
 public UserPage(UserData userData, MainWindow mainWindow)
 {
     InitializeComponent();
     _userdata        = userData;
     _mw              = mainWindow;
     _vm              = new UserPageVM(_mw, this);
     this.DataContext = _vm;
     SetDatas();
 }
        public IActionResult Watchlist(int?page)

        {
            var pagenumber = page ?? 1;

            int        id    = Convert.ToInt32(TempData["ID"]);
            UserPageVM model = new UserPageVM();

            model.UserWatch = _context.WatchLists.Include(x => x.Movie).ThenInclude(Movie => Movie.MoviePeople).ThenInclude(MoviePerson => MoviePerson.Person).Include(x => x.Movie).ThenInclude(Movie => Movie.Rates).Where(q => q.UserID == id && q.IsDeleted == false).ToList().ToPagedList(pagenumber, 5);

            model.User = _context.Users.FirstOrDefault(q => q.ID == id);

            return(View(model));
        }
        public async Task <IActionResult> LogIn(AccountLoginVM loginVM, UserPageVM userPageVM)
        {
            if (!ModelState.IsValid)
            {
                return(View(loginVM));
            }

            var result = await _signInManager.PasswordSignInAsync(loginVM.Username, loginVM.Password, false, false);

            if (!result.Succeeded)
            {
                ModelState.AddModelError(nameof(AccountLoginVM.Username), result.ToString());
                return(View(loginVM));
            }

            if (string.IsNullOrWhiteSpace(loginVM.ReturnUrl))
            {
                return(Redirect("~/Shows/UserPage"));
            }
            else
            {
                return(Redirect(loginVM.ReturnUrl));
            }
        }
Example #7
0
 public EditUserModal(UserPageVM vm)
 {
     InitializeComponent();
     DataContext = vm;
 }
Example #8
0
 public NewUser(UserPageVM vm)
 {
     InitializeComponent();
     DataContext = vm;
 }
 public NewUserCommand(UserPageVM vm)
 {
     VM = vm;
 }
 public UpdateUserCommand(UserPageVM vm)
 {
     VM = vm;
 }
 public UpdateUserPassword(UserPageVM vm)
 {
     VM = vm;
 }
 public NewPasswordModal(UserPageVM vm)
 {
     InitializeComponent();
     DataContext = vm;
 }