public IActionResult Dashboard() { int?UserId = HttpContext.Session.GetInt32("UserId"); if (UserId == null) { return(RedirectToAction("Login", "LogReg")); } else { var client = _clientFactory.CreateClient("BaseAddress"); var response = client.GetAsync($"/3/discover/movie?api_key=002100dd35529be2881e0dbc97008958&language=en-US&sort_by=popularity.desc&page=1").Result; var json = response.Content.ReadAsStringAsync().Result; var deserialize = JsonConvert.DeserializeObject <SearchResult>(json); User user = _context.Users.FirstOrDefault(u => u.UserId == UserId); DashboardWrapper WMod = new DashboardWrapper(); WMod.User = user; WMod.Recommend = GenerateRecommended(); WMod.Genre = FavoriteGenreReturn((int)user.Genre); WMod.Budget = FavoriteBudgetReturn(user.Budget); WMod.Rating = FavoriteRatingReturn(user.Rating); WMod.Certification = FavoriteCertificationReturn(user.Certification); var gclient = _clientFactory.CreateClient("BaseAddress"); var gresponse = gclient.GetAsync($"/3/genre/movie/list?api_key=002100dd35529be2881e0dbc97008958").Result; var gjson = gresponse.Content.ReadAsStringAsync().Result; var gdeserialize = JsonConvert.DeserializeObject <AllGenres>(gjson); WMod.AllGenres = gdeserialize; return(View("Dashboard", WMod)); } }
public IActionResult Index(DashboardWrapper newView) { if (newView.Search == null) { newView.RecentProducts = dbContext.Products .OrderByDescending(p => p.CreatedAt).Take(5) .ToList(); } else { newView.RecentProducts = dbContext.Products .Where(p => p.ProductName.Contains(newView.Search) || p.ProductName.Contains(newView.Search)) .OrderByDescending(p => p.CreatedAt).Take(5) .ToList(); } newView.RecentOrders = dbContext.Orders .Include(o => o.Customer) .Include(o => o.Product) .OrderByDescending(o => o.CreatedAt).Take(3) .ToList(); newView.RecentCustomers = dbContext.Customers .OrderByDescending(c => c.CreatedAt).Take(3) .ToList(); return(View(newView)); }
// dashboard public IActionResult dashboard() { // block pages is not in session if (HttpContext.Session.GetInt32("UserId") == null) { return(RedirectToAction("index")); } // user in session int UserIdInSession = (int)HttpContext.Session.GetInt32("UserId"); // filter user in session with db User UserIndb = _context.Users.FirstOrDefault(u => u.UserId == UserIdInSession); ViewBag.ToDisplay = UserIndb; // Get all guest from db set ViewBag.TodoListItems = _context.TodoLists .Where(us => us.UserId == UserIdInSession) .ToList(); DashboardWrapper wMode = new DashboardWrapper(); return(View("dashboard", wMode)); }
public IActionResult Dashboard() { if (!CheckUser()) { return(RedirectToAction("Login", "User")); } DashboardWrapper data = new DashboardWrapper(); data.NewestProducts = _db.Products .OrderByDescending(p => p.CreateAt) .Take(5) .ToArray(); data.RecentOrders = _db.Orders .Include(o => o.Customer) .Include(o => o.OrderedProduct) .OrderByDescending(o => o.CreateAt) .Take(3) .ToArray(); data.NewestUsers = _db.Users .OrderByDescending(u => u.CreatedAt) .Take(3) .ToArray(); return(View("Dashboard", data)); }
public RedirectToActionResult LikeIdea(DashboardWrapper FromForm) { // get user id from session int?LoggedId = HttpContext.Session.GetInt32("UserId"); // check if user is logged in, if not logged in, redirect to Index if (LoggedId == null) { return(RedirectToAction("Index")); } // user is logged in , but we need to check if they have already liked this idea previously // (Like newLike = FromForm.Form; could have used this and created that variable) // pull out id of idea to join int IdeaBeingLikedId = FromForm.LikeForm.IdeaId; //to not let a user chose the same idea twice// // check if there are ALREADY any existing "Liker Ids (objects) from this loggedid that match the ideaid & like id AND the user id == the logged user id if (DbContext.Likes.Any(e => e.UserId == (int)LoggedId && e.IdeaId == IdeaBeingLikedId)) { ModelState.AddModelError("LikeTwice", "You sure like this one! You've already clicked like and here, you can only like an idea once."); return(RedirectToAction("Dashboard", FromForm)); } // insert logged in user into new "LikeId" object (which is passed in via LikeForm) FromForm.LikeForm.UserId = (int)LoggedId; DbContext.Likes.Add(FromForm.LikeForm); DbContext.SaveChanges(); return(RedirectToAction("Dashboard")); }
public IActionResult OneIdea(int IdeaId) { int?LoggedId = HttpContext.Session.GetInt32("UserId"); if (LoggedId == null) { return(RedirectToAction("Index")); } DashboardWrapper oneidea = new DashboardWrapper() { //also am converting the sets into lists// AllIdeas = DbContext.Ideas // include 1-to-many related model (User) (Cannot do a theninlcude from this one) .Include(i => i.Creator) // include many-to-many related model (List<likes>), THENINCLUDE the other end of the relationship .Include(i => i.UsersWhoLikeThisIdea) .ThenInclude(l => l.Liker) .ToList(), IdeaForm = DbContext.Ideas .FirstOrDefault(i => i.IdeaId == (int)IdeaId), LoggedUser = DbContext.Users .FirstOrDefault(u => u.UserId == (int)LoggedId), }; return(View("OneIdea", oneidea)); }
public ActionResult Investor(int?page, string listingStatus = null) { var investorDashboardBA = new Dashboard(); var serialization = new Serialization(); var HashCriteria = new Hashtable(); var actualCriteria = string.Empty; var dashboardWrapper = new DashboardWrapper(); HashCriteria.Add("UserID", userID); actualCriteria = serialization.SerializeBinary((object)HashCriteria); var result = investorDashboardBA.GetInvestorDashboard(actualCriteria); dashboardWrapper.InvestorListing = (List <InvestorDashboardModel>)(serialization.DeSerializeBinary(Convert.ToString(result))); var tempActiveListings = new List <InvestorDashboardModel>(); var tempFavoriteListings = new List <InvestorDashboardModel>(); foreach (var item in dashboardWrapper.InvestorListing) { if (item.IsFavorite && item.SentMessageCount > 0) { item.Status = "Favorite"; tempFavoriteListings.Add(item); tempActiveListings.Add(item); item.ImagePath = CheckFileExists(item.ImagePath, "ListingImagePath", Convert.ToString(item.ID)); } else if (item.IsFavorite && item.SentMessageCount <= 0) { item.Status = "Favorite"; tempFavoriteListings.Add(item); item.ImagePath = CheckFileExists(item.ImagePath, "ListingImagePath", Convert.ToString(item.ID)); } else if (!item.IsFavorite && item.SentMessageCount > 0) { item.Status = "Active"; tempActiveListings.Add(item); item.ImagePath = CheckFileExists(item.ImagePath, "ListingImagePath", Convert.ToString(item.ID)); } } var pageSize = 12; var pageIndex = 1; pageIndex = page.HasValue ? Convert.ToInt32(page) : 1; dashboardWrapper.PagedListInvestorActiveListing = tempActiveListings.ToPagedList(pageIndex, pageSize); dashboardWrapper.PagedListInvestorFavoriteListing = tempFavoriteListings.ToPagedList(pageIndex, pageSize); if (listingStatus != null) { if (listingStatus == "Active") { return(PartialView("_InvestorMyListings", dashboardWrapper.PagedListInvestorActiveListing)); } if (listingStatus == "Favorite") { return(PartialView("_InvestorMyListings", dashboardWrapper.PagedListInvestorFavoriteListing)); } } return(View("Investor", dashboardWrapper.PagedListInvestorActiveListing)); }
public async Task <IActionResult> Manage() { if (!await _authorizationService.AuthorizeAsync(User, Permissions.ManageAdminDashboard)) { return(Forbid()); } // Set Manage Dashboard Feature Request.HttpContext.Features.Set(new DashboardFeature() { IsManageRequest = true }); var dashboardCreatable = new List <SelectListItem>(); var widgetContentTypes = _contentDefinitionManager.ListTypeDefinitions() .Where(t => !string.IsNullOrEmpty(t.GetSettings <ContentTypeSettings>().Stereotype) && t.GetSettings <ContentTypeSettings>().Stereotype.Contains("DashboardWidget")) .OrderBy(x => x.DisplayName); foreach (var ctd in widgetContentTypes) { var contentItem = await _contentManager.NewAsync(ctd.Name); contentItem.Owner = User.FindFirstValue(ClaimTypes.NameIdentifier); var authorized = await _authorizationService.AuthorizeAsync(User, CommonPermissions.EditContent, contentItem); if (authorized) { dashboardCreatable.Add(new SelectListItem(ctd.DisplayName, ctd.Name)); } } var widgets = await _adminDashboardService.GetWidgetsAsync(x => x.Latest); var wrappers = new List <DashboardWrapper>(); foreach (var item in widgets) { var wrapper = new DashboardWrapper { Dashboard = item, Content = await _contentItemDisplayManager.BuildDisplayAsync(item, _updateModelAccessor.ModelUpdater, "DetailAdmin") }; wrappers.Add(wrapper); } var model = new AdminDashboardViewModel { Dashboards = wrappers.ToArray(), Creatable = dashboardCreatable }; return(View(model)); }
public JsonResult displayTodoList() { int UserIdInSession = (int)HttpContext.Session.GetInt32("UserId"); DashboardWrapper wMode = new DashboardWrapper(); List <TodoList> itemList = _context.TodoLists .Where(us => us.UserId == UserIdInSession) .ToList(); // ViewBag.TodoListItems = _context.TodoLists // .Where(us => us.UserId == UserIdInSession) // .ToList(); return(Json(new { data = itemList })); }
[HttpGet("dashboard")] //Http Method and the route public IActionResult Dashboard() //When in doubt, use IActionResult { int?Uuid = HttpContext.Session.GetInt32("Uuid"); if (Uuid > 0) { ViewBag.YourUuid = Uuid; //the viewbag way User YourUser = _context.Users.FirstOrDefault(u => u.UserId == Uuid); DashboardWrapper DWMod = new DashboardWrapper() { ThisUser = YourUser, AllWeddings = _context.Weddings.Include(w => w.UsersWhoRSVPed).ToList() }; //end DWMod return(View("Dashboard", DWMod)); //or whatever you want to return } else { System.Console.WriteLine("Can't access account page, reg or login first"); return(Redirect("/")); } }
public IActionResult OneCreator(int UserId) { // int? LoggedId = HttpContext.Session.GetInt32("UserId"); // if(LoggedId == null) // { // return RedirectToAction("Index"); // } DashboardWrapper OneUser = new DashboardWrapper() { //going into the DB sets and converting them into lists// AllUsers = DbContext.Users // include 1-to-many related model (User). Cannot do a "theninlcude" from 1-to-many. .Include(u => u.CreatedByUser).ToList(), AllIdeas = DbContext.Ideas // include many-to-many related model (List<likes>). Can use the "theninlcude" to reach the other end of the relationship. .Include(i => i.UsersWhoLikeThisIdea) .ThenInclude(l => l.Liker) .ToList(), }; return(View("OneCreator", UserId)); }
public IActionResult Dashboard() { int?LoggedId = HttpContext.Session.GetInt32("UserId"); if (LoggedId == null) { return(RedirectToAction("Index")); } DashboardWrapper Wrap = new DashboardWrapper() { AllWeddings = DbContext.Weddings .Include(w => w.Creator) .Include(w => w.GuestsAttending) .ThenInclude(g => g.Guest) .Where(w => w.Date > DateTime.Today) .ToList(), LoggedUser = DbContext.Users .FirstOrDefault(u => u.UserId == (int)LoggedId) }; return(View("Dashboard", Wrap)); }
public IActionResult Dashboard() { int?LoggedId = HttpContext.Session.GetInt32("UserId"); if (LoggedId == null) { return(RedirectToAction("Registration")); } DashboardWrapper WMod = new DashboardWrapper() { AllWeddings = dbContext.Weddings .Include(w => w.Planner) .Include(w => w.GuestsAttending) .ThenInclude(r => r.Guest) .Where(w => w.Date > DateTime.Today) .ToList(), LoggedUser = dbContext.Users.FirstOrDefault(u => u.UserId == (int)LoggedId) }; return(View("Dashboard", WMod)); }
public IActionResult Home() { if (HttpContext.Session.GetInt32("Uuid") == null) { return(Redirect("/")); } int Uuid = (int)HttpContext.Session.GetInt32("Uuid"); User You = _context.Users.FirstOrDefault(u => u.UserId == Uuid); List <User> Creators = _context.Users.Include(u => u.PActivitiesCreated).ToList(); DashboardWrapper DWmod = new DashboardWrapper() { ThisUser = You, AllActivities = _context.Activities .Include(a => a.Creator) .Include(a => a.UsersWhoJoined) .OrderBy(a => a.DateNTime) .ToList() }; return(View("Home", DWmod)); }
public IActionResult Dashboard() { // get user id from session int?LoggedId = HttpContext.Session.GetInt32("UserId"); // check if user is logged in, if not logged in, redirect to Index if (LoggedId == null) { return(RedirectToAction("Index")); } DashboardWrapper thing = new DashboardWrapper() { AllIdeas = DbContext.Ideas .Include(i => i.Creator) .Include(i => i.UsersWhoLikeThisIdea) .ThenInclude(l => l.Liker) .ToList(), LoggedUser = DbContext.Users .FirstOrDefault(u => u.UserId == (int)LoggedId) }; return(View("Dashboard", thing)); }
public ActionResult Admin(int?page, string Tab = null, string sortingOrder = "RecentlyPosted", string searchText = "") { searchText = searchText.Replace("'", "''"); Serialization serialization = new Serialization(); DashboardWrapper dashboardWrapper = new DashboardWrapper(); Hashtable HashCriteria = new Hashtable(); Hashtable UsersHashCriteria = new Hashtable(); Hashtable ResourcesHashCriteria = new Hashtable(); Hashtable TestimonialsHashCriteria = new Hashtable(); string actualCriteria; actualCriteria = serialization.SerializeBinary((object)HashCriteria); int pageSize = 8; int pageIndex = 1; pageIndex = page.HasValue ? Convert.ToInt32(page) : 1; if (Tab == "Users") { UserRegistration userRecords = new UserRegistration(); UsersHashCriteria.Add("Name", searchText); UsersHashCriteria.Add("SortingOrder", sortingOrder); actualCriteria = serialization.SerializeBinary((object)UsersHashCriteria); var users = userRecords.GetUserSpecificDetails(actualCriteria); dashboardWrapper.Users = (List <UserProfileEditModel>)(serialization.DeSerializeBinary(Convert.ToString(users))); dashboardWrapper.PagedListUsers = dashboardWrapper.Users.ToPagedList(pageIndex, pageSize); return(PartialView("_AdminUsersTab", dashboardWrapper.PagedListUsers)); } else if (Tab == "Resources") { Learn learnBA = new Learn(); ResourcesHashCriteria.Add("SortingOrder", sortingOrder); ResourcesHashCriteria.Add("SearchText", searchText); ResourcesHashCriteria.Add("IsAdminDashboard", "1"); actualCriteria = serialization.SerializeBinary((object)ResourcesHashCriteria); var resourcesList = learnBA.GetLearnListingDetails(actualCriteria); dashboardWrapper.Resources = (List <LearnModel>)(serialization.DeSerializeBinary(Convert.ToString(resourcesList))); dashboardWrapper.PagedListResource = dashboardWrapper.Resources.ToPagedList(pageIndex, pageSize); return(PartialView("_AdminResourcesTab", dashboardWrapper.PagedListResource)); } else if (Tab == "Testimonials") { Testimonial testimonialBA = new Testimonial(); TestimonialsHashCriteria.Add("SortingOrder", sortingOrder); TestimonialsHashCriteria.Add("SearchText", searchText); actualCriteria = serialization.SerializeBinary((object)TestimonialsHashCriteria); dashboardWrapper.Testimonials = testimonialBA.GetAllTestimonial(actualCriteria); dashboardWrapper.PagedListTestimonial = dashboardWrapper.Testimonials.ToPagedList(pageIndex, pageSize); return(PartialView("_AdminTestimonialsTab", dashboardWrapper.PagedListTestimonial)); } else { InvestorListings investorListings = new InvestorListings(); InvestorListingWrapper investorListingWrapper = new InvestorListingWrapper(); investorListingWrapper.SortingOrder = sortingOrder; investorListingWrapper.ListingTypeIds = string.Empty; HashCriteria.Add("ID", investorListingWrapper.ListingTypeIds); HashCriteria.Add("LocationName", investorListingWrapper.LocationName); HashCriteria.Add("SortingOrder", investorListingWrapper.SortingOrder); HashCriteria.Add("Name", searchText); HashCriteria.Add("LoanID", investorListingWrapper.LoanID); HashCriteria.Add("LienPositionID", investorListingWrapper.LienPositionID); HashCriteria.Add("LoanStatusID", investorListingWrapper.LoanStatusID); HashCriteria.Add("State", investorListingWrapper.State); HashCriteria.Add("LoanTypeID", investorListingWrapper.LoanTypeID); HashCriteria.Add("Address", investorListingWrapper.Address); HashCriteria.Add("PropertyTypeID", investorListingWrapper.PropertyTypeID); HashCriteria.Add("MinPrincipalBalance", 0); HashCriteria.Add("MaxPrincipalBalance", 0); HashCriteria.Add("City", investorListingWrapper.City); HashCriteria.Add("MinInterestRate", 0); HashCriteria.Add("MaxInterestRate", 0); HashCriteria.Add("MinAskingPrice", 0); HashCriteria.Add("MaxAskingPrice", 0); HashCriteria.Add("UserID", userID); actualCriteria = serialization.SerializeBinary((object)HashCriteria); var listing = investorListings.GetDealDetails(actualCriteria); dashboardWrapper.InvestorAdminListing = (List <InvestorListingsModel>)(serialization.DeSerializeBinary(Convert.ToString(listing))); dashboardWrapper.PagedListAdminListings = dashboardWrapper.InvestorAdminListing.ToPagedList(pageIndex, pageSize); //Users default load actualCriteria = string.Empty; UserRegistration userRecords = new UserRegistration(); UsersHashCriteria.Add("SortingOrder", sortingOrder); actualCriteria = serialization.SerializeBinary((object)UsersHashCriteria); dashboardWrapper.Users = new List <UserProfileEditModel>(); var users = userRecords.GetUserSpecificDetails(actualCriteria); dashboardWrapper.Users = (List <UserProfileEditModel>)(serialization.DeSerializeBinary(Convert.ToString(users))); dashboardWrapper.PagedListUsers = dashboardWrapper.Users.ToPagedList(pageIndex, pageSize); //Resources default load actualCriteria = string.Empty; Learn learnBA = new Learn(); //For Learn LearnModel learn = new LearnModel(); ResourcesHashCriteria.Add("SortingOrder", sortingOrder); ResourcesHashCriteria.Add("IsAdminDashboard", "1"); actualCriteria = serialization.SerializeBinary((object)ResourcesHashCriteria); var resourcesList = learnBA.GetLearnListingDetails(actualCriteria); dashboardWrapper.Resources = (List <LearnModel>)(serialization.DeSerializeBinary(Convert.ToString(resourcesList))); dashboardWrapper.PagedListResource = dashboardWrapper.Resources.ToPagedList(pageIndex, pageSize); Testimonial testimonialBA = new Testimonial(); TestimonialsHashCriteria.Add("SortingOrder", sortingOrder); TestimonialsHashCriteria.Add("SearchText", searchText); actualCriteria = serialization.SerializeBinary((object)TestimonialsHashCriteria); dashboardWrapper.Testimonials = testimonialBA.GetAllTestimonial(actualCriteria); dashboardWrapper.PagedListTestimonial = dashboardWrapper.Testimonials.ToPagedList(pageIndex, pageSize); if (Tab != null) { return(PartialView("_AdminListingsTab", dashboardWrapper.PagedListAdminListings)); } return(View("AdminDashboard", dashboardWrapper)); } }