Exemplo n.º 1
0
        public IActionResult SaveCookie(IndexVm model)
        {
            //send user back to Index if he didn't pick a valid cookie from the list
            if (!AllBiscuits.Select(c => c.ImageName).Contains(model.SelectedBiscuitImage))
            {
                return(RedirectToAction("Index"));
            }

            //set cookie options
            var cookieOptions = new CookieOptions
            {
                HttpOnly = true,                //javascript can't touch this.
                SameSite = SameSiteMode.Strict  //protect against XSRF attacks
            };

            if (model.IsPersistent) //set cookie to be auto-removed in 1 year from now
            {
                cookieOptions.Expires = DateTimeOffset.Now.AddYears(1);
            }

            //add the cookie
            Response.Cookies.Append(COOKIENAME, model.SelectedBiscuitImage, cookieOptions);

            return(RedirectToAction("Index"));
        }
        public IActionResult AddBeer(IndexVm model)
        {
            //get the selected beer from form
            BeerVm selectedBeer = AllBeers.FirstOrDefault(b => b.Name == model.SelectedBeerName);

            if (selectedBeer == null)
            {
                return(RedirectToAction("Index"));
            }

            //retrieve serialized collection from session
            string        serializedBeers     = HttpContext.Session.GetString(STATEKEY);
            List <BeerVm> beersInShoppingList = new List <BeerVm>();

            if (serializedBeers != null)
            {
                //deserialize JSON string to it's original form
                beersInShoppingList = JsonConvert.DeserializeObject <List <BeerVm> >(serializedBeers);
            }
            //add beer to the List
            beersInShoppingList.Add(selectedBeer);
            //seriaize List to JSON string
            serializedBeers = JsonConvert.SerializeObject(beersInShoppingList);
            //store JSON string in Session State
            HttpContext.Session.SetString(STATEKEY, serializedBeers);

            return(RedirectToAction("Index"));
        }
        public static IndexVm GetIndexSearchVm()
        {
            IndexVm indexVm = new IndexVm();

            indexVm.PageType = PageType.Index;
            indexVm.Seo      = SeoHelper.GetSeo(indexVm);
            indexVm.Criteria = GetInitSearchCriteriaVm();
            CountryStubSearchModel countryStubSearchModel = new CountryStubSearchModel();

            countryStubSearchModel.Criteria         = indexVm.Criteria.ToSearchCriteria();
            countryStubSearchModel.MaxCount         = ConfigurationManager.Instance.IndexStubCitiesMaxCount;
            countryStubSearchModel.IsMarketAreaOnly = true;
            List <CityListingsInfo> result = SearchBc.Instance.SearchStubCities(countryStubSearchModel).Result;

            indexVm.Result.Add(SearchType.ActiveAdultCommunities, result.OrderByDescending((CityListingsInfo li) => li.AdultCommunitiesCount).Take(countryStubSearchModel.MaxCount).MapToCitiesLinks(SearchType.ActiveAdultCommunities, addCounting: false));
            indexVm.Result.Add(SearchType.ActiveAdultHomes, result.OrderByDescending((CityListingsInfo li) => li.AdultHomesCount).Take(countryStubSearchModel.MaxCount).MapToCitiesLinks(SearchType.ActiveAdultHomes, addCounting: false));
            indexVm.Result.Add(SearchType.SeniorHousingAndCare, result.OrderByDescending((CityListingsInfo li) => li.SeniorHousingCount).Take(countryStubSearchModel.MaxCount).MapToCitiesLinks(SearchType.SeniorHousingAndCare, addCounting: false));
            indexVm.Result.Add(SearchType.ProductsAndServices, result.OrderByDescending((CityListingsInfo li) => li.ServicesCount).Take(countryStubSearchModel.MaxCount).MapToCitiesLinks(SearchType.ProductsAndServices, addCounting: false));
            List <KeyValuePair <int, string> > shcCategoriesForCommunity = ItemTypeBc.Instance.GetShcCategoriesForCommunity();
            List <int> ShcCategories = new List <int>();

            indexVm.Refine = new CommunityRefineVm();
            indexVm.SearchBar.SHCategories = shcCategoriesForCommunity.MapToSelectListItemList(ShcCategories);
            //indexVm.Refine.ShcCategories =
            return(indexVm);
        }
Exemplo n.º 4
0
        public async Task <IActionResult> Connect()
        {
            var token = HttpContext.Session.GetObjectFromJson <GetAccessTokenFromCodeResponse>("AccessToken");
            var model = new IndexVm()
            {
                AccessToken = token
            };

            if (!string.IsNullOrEmpty(model.AccessToken?.AccessToken))
            {
                var result = await GetApi().Auth.GetClaims(model.AccessToken.AccessToken);

                //var result = User.Claims.Select(x => new GetClaimsResponseItem()
                //{
                //    Type = x.Type,
                //    Value = x.Value
                //}).ToList();
                model.Claims = result;
            }
            else
            {
                model.ConnectUrl = GetApi().Auth.GetConnectUrl(_settings.ApplicationId, Url.Action("Callback", "Pinch", null, Request.Scheme));
            }

            return(View(model));
        }
Exemplo n.º 5
0
        public ActionResult Index(IndexVm vm)
        {
            const string cookieName         = "loginAllowed";
            var          loginAllowedCookie = new HttpCookie(cookieName);

            if (vm.UserName == "serge")
            {
                vm.IsLoginSuccessful = true;

                //add cookie. we can also add MAC guid, random number, name could be encrypted etc
                loginAllowedCookie.Values["UserName"] = vm.UserName;
                loginAllowedCookie.Expires            = DateTime.Now.AddMinutes(2);
                System.Web.HttpContext.Current.Response.Cookies.Add(loginAllowedCookie);
            }
            else
            {
                vm.IsLoginSuccessful          = false;
                vm.UnsuccesfullAttemptToLogin = true;
                vm.UserName = String.Empty;
                loginAllowedCookie.Expires = DateTime.Now.AddDays(-1);
                System.Web.HttpContext.Current.Response.Cookies.Add(loginAllowedCookie);
                System.Web.HttpContext.Current.Response.Cookies.Remove(cookieName);
            }



            return(View(vm));
        }
Exemplo n.º 6
0
        public async Task <ActionResult> UserDetails(IndexVm model)
        {
            AspNetUser user = null;

            if (model.NationalId == null)
            {
                return(View("Error"));
            }
            if (ModelState.IsValid)
            {
                var context = ApplicationDbContext.Create();

                user = await context.Users.SingleOrDefaultAsync(x => x.NationalId == model.NationalId);

                if (user == null)
                {
                    ModelState.AddModelError("", "تأكد من ان الرقم القومى مسجل");
                    return(View("Index"));
                }
                return(View(new UserDetailsVM
                {
                    NationalId = user.NationalId,
                    Email = user.Email,
                    EmailConfirmed = user.EmailConfirmed,
                    PhoneNumber = user.PhoneNumber,
                    LockoutEnabled = user.LockoutEnabled,
                    LockoutEndDateUtc = user.LockoutEndDateUtc
                }));
            }
            return(View());
        }
Exemplo n.º 7
0
        public IActionResult Index(IndexVm vm)
        {
            Dictionary <string, int> wordDict = null;

            if (!string.IsNullOrEmpty(vm.WebPageUrl))
            {
                wordDict = _webPageParserService.GetWordFrequency(vm.WebPageUrl);
            }

            if (wordDict != null && wordDict.Count > 0)
            {
                vm.Words = wordDict.Select(p => new WordVm()
                {
                    Frequency = p.Value,
                    Text      = p.Key
                })
                           .OrderByDescending(p => p.Frequency)
                           .Take(100)
                           .ToList();

                vm.WordFrequencySum = vm.Words.Sum(w => w.Frequency);

                _dataService.SaveWords(vm.Words);

                //just to shuffle the words
                vm.Words = vm.Words.OrderBy(x => Guid.NewGuid()).ToList();
            }


            return(View(vm));
        }
        public async Task <IActionResult> Index()
        {
            ImageUploads imgUploads   = new ImageUploads();
            IndexVm      listOfImages = new IndexVm()
            {
                Images = await _imageRepo.GetAllImages(StaticDetails.GetImages)
                         //HttpContext.User.Identity.IsAuthenticated ? await _imageRepo.GetAllImageByIdAsync
                         //(StaticDetails.GetSingleImage, UserId(), HttpContext.Session.GetString("JWToken")) :
            };

            imgUploads.IndexViewModel = listOfImages;
            ViewBag.ImageSuccess      = TempData["ImageSuccess"];
            ViewBag.ImageExist        = TempData["ImageExist"];
            ViewBag.Deleted           = TempData["ImageDeleted"];
            if (User.Identity.IsAuthenticated)
            {
                //ViewData["ReturnUrl"] = returnUrl;

                //HttpContext.Session.Clear();
                if (listOfImages.Images != null)
                {
                    TempData["Authenticated"] = User.Identity.IsAuthenticated ? "Authenticated" : null;
                    return(View(imgUploads));
                }

                return(View(imgUploads));
            }
            return(View(imgUploads));
        }
Exemplo n.º 9
0
        public IActionResult Index()
        {
            var vm = new IndexVm()
            {
            };

            return(View(vm));
        }
Exemplo n.º 10
0
 public ActionResult Index(IndexVm model)
 {
     if (ModelState.IsValid)
     {
         return(RedirectToAction("UserDetails", new { model.NationalId }));
     }
     return(View(model));
 }
        public IActionResult Index(bool?keep)
        {
            var indexVm = new IndexVm {
                KeepUntilRemoved = keep ?? false
            };

            return(View(indexVm));
        }
Exemplo n.º 12
0
        public ActionResult Index()
        {
            var model = new IndexVm()
            {
                Beers = _dbContext.Beers.ToList()
            };

            return(View(model));
        }
Exemplo n.º 13
0
        public ActionResult Index()
        {
            var model = new IndexVm()
            {
                Plans = Plan.Plans
            };

            return(View(model));
        }
Exemplo n.º 14
0
        public ActionResult Index()
        {
            var model = new IndexVm()
            {
                BillingPlans = _dbContext.BillingPlans.Where(x => x.Name.Contains("092020")).ToList(),
                Products     = _dbContext.Products.Where(x => x.Name.Contains("092020")).ToList()
            };

            return(View(model));
        }
Exemplo n.º 15
0
        public async Task <IActionResult> Index()
        {
            IndexVm all = new IndexVm
            {
                NationalParkList = await _npRepo.GetAllAsync(SD.NationalParkAPIPath),
                TrailList        = await _tRepo.GetAllAsync(SD.TrailAPIPath)
            };

            return(View(all));
        }
Exemplo n.º 16
0
        public async Task <IActionResult> Index()
        {
            var nationalParksAndTrails = new IndexVm
            {
                NationalParks = await _npRepo.GetAllAsync(StaticDetails.NationalParksApiPath),
                Trails        = await _trailRepo.GetAllAsync(StaticDetails.TrailsApiPath)
            };

            return(View(nationalParksAndTrails));
        }
Exemplo n.º 17
0
        public IActionResult Index(int pageIndex = 1)
        {
            if (HttpContext.Session.GetInt32("LoginLevel") != 2)
            {
                ViewBag.checkLogin = 0;
                return(View("../Home/AddCart"));
            }
            IndexVm CategoryIndexVM = _categoryService.GetCategoryListVm(pageIndex);

            return(View(CategoryIndexVM));
        }
Exemplo n.º 18
0
        public IActionResult Index()
        {
            var data  = _taskAppService.GetAll();
            var model = new IndexVm
            {
                Tasks = data,
                Task  = new TaskVm()
            };

            return(View(model));
        }
Exemplo n.º 19
0
        public IActionResult Index()
        {
            var model = new IndexVm();

            model.BulkBuys = _context.BulkBuys
                             .OrderByDescending(x => x.CreatedDate)
                             .Select(BulkBuyDto.Projection)
                             .ToList();

            return(View(model));
        }
Exemplo n.º 20
0
        //
        //public BrandIndexVm BrandIndexVM { get; set; }
        public IActionResult Index(string searchString, int pageIndex = 1)
        {
            if (HttpContext.Session.GetInt32("LoginLevel") != 2)
            {
                ViewBag.checkLogin = 0;
                return(View("../Home/AddCart"));
            }
            IndexVm BrandIndexVM = _brandService.GetBrandListVm(searchString, pageIndex);

            return(View(BrandIndexVM));
        }
        public async Task <IActionResult> Index()
        {
            IndexVm vm = new IndexVm()
            {
                MenuItems  = await _db.MenuItems.Include(c => c.Category).Include(s => s.SubCategory).ToListAsync(),
                Categories = await _db.Categories.ToListAsync(),
                Coupons    = await _db.Coupons.Where(c => c.IsActive == true).ToListAsync()
            };

            return(View(vm));
        }
Exemplo n.º 22
0
        public ActionResult Index()
        {
            IndexVm indexVm = new IndexVm();
            var     tolet   = db.ToLetPublishs.ToList();

            indexVm.ToLetPublishs = tolet;

            var customers = db.Customers.ToList();

            indexVm.Customers = customers;
            return(View(indexVm));
        }
Exemplo n.º 23
0
        public IActionResult Index(string searchString, int pageIndex = 1, int pageSize = 5, int?status = null)
        {
            if (HttpContext.Session.GetInt32("LoginLevel") != 2)
            {
                ViewBag.checkLogin = 0;
                return(View("../Home/AddCart"));
            }
            IndexVm UserIndexVM = _userService.GetUserListVm(searchString, pageIndex, pageSize, status);

            ViewBag.pageSize = pageSize;
            ViewBag.status   = status;
            return(View(UserIndexVM));
        }
Exemplo n.º 24
0
        public async Task <ActionResult> Index()
        {
            IndexVm viewModel = new IndexVm();

            viewModel.Donations = await db.Donations.ToListAsync();

            viewModel.Subscriptions = await db.Subscriptions.ToListAsync();

            viewModel.Partners = await db.Partners.Include(p => p.Donations).Include(p => p.Subscriptions).ToListAsync();

            viewModel.Plans = await db.Plans.Include(p => p.Donations).Include(p => p.Subscriptions).ToListAsync();

            return(View(viewModel));
        }
        public IActionResult Index()
        {
            var vm = new IndexVm();

            vm.Beers        = AllBeers;
            vm.ShoppingCart = new List <BeerVm>();

            string serializedBeers = HttpContext.Session.GetString(STATEKEY);

            if (serializedBeers != null)
            {
                vm.ShoppingCart = JsonConvert.DeserializeObject <List <BeerVm> >(serializedBeers);
            }
            return(View("Index", vm));
        }
Exemplo n.º 26
0
        public ActionResult Index()
        {
            var vm = new IndexVm();

            if (Session["LoggedIn"] == null)
            {
                vm.IsLoginSuccessful = false;
            }
            else
            {
                vm.IsLoginSuccessful = true;
            }

            return(View(vm));
        }
        public IndexVm GetIndexPageVm()
        {
            var page = new IndexVm();

            var courses = this.Context.Courses.ToList();
            var student = this.Context.Students.ToList();

            var courseVms  = Mapper.Map <IEnumerable <Course>, IEnumerable <CourseVm> >(courses);
            var studentVms = Mapper.Map <IEnumerable <Student>, IEnumerable <StudentVm> >(student);

            page.Courses  = courseVms;
            page.Students = studentVms;

            return(page);
        }
Exemplo n.º 28
0
        public IActionResult Index()
        {
            var cultureInfo = CultureInfo.GetCultures(CultureTypes.AllCultures);
            var model       = new IndexVm();

            model.Countries = new Dictionary <string, string>();

            foreach (var item in cultureInfo)
            {
                if (!model.Countries.ContainsKey(item.ThreeLetterISOLanguageName))
                {
                    model.Countries.Add(item.ThreeLetterISOLanguageName, item.EnglishName);
                }
            }

            return(View(model));
        }
Exemplo n.º 29
0
        public IActionResult Index(string searchString, string brand, string category, int pageIndex = 1, int pageSize = 5, int?status = null)
        {
            if (HttpContext.Session.GetInt32("LoginLevel") != 2)
            {
                ViewBag.checkLogin = 0;
                return(View("../Home/AddCart"));
            }
            ViewData["Brand"]        = brand;
            ViewData["Category"]     = category;
            ViewData["SearchString"] = searchString;

            IndexVm ProductIndexVM = _productService.GetProductListVm(searchString, brand, category, pageIndex, pageSize, status);

            ViewBag.pageSize = pageSize;
            ViewBag.status   = status;
            return(View(ProductIndexVM));
        }
Exemplo n.º 30
0
        public async Task <IActionResult> Index()
        {
            IndexVm vm = new IndexVm(); //will be passed to Index View

            //1. get teacher with Id == 1
            vm.TeacherWidthIdOne = await schoolContext.Teachers.FindAsync(5L);

            //2. get students born before 2000, ordered by Name
            vm.StudentsBornBefore2k = await schoolContext.Students
                                      .Where(s => s.Birthdate.Year < 2000)
                                      .OrderBy(s => s.Name)
                                      .ToListAsync();

            //3. get total amount of scholarships
            vm.TotalScholarships = await schoolContext.Students
                                   .SumAsync(s => s.Scholarship) ?? 0; //return 0 if null

            //4. get scholarship student with studentinfo loaded
            //   order by scholarship, then by name
            vm.ScholarshipStudentsWithInfo = await schoolContext.Students
                                             .Include(s => s.ContactInfo)
                                             .Where(s => s.Scholarship != null)
                                             .OrderBy(s => s.Scholarship)
                                             .ThenBy(s => s.Name)
                                             .ToListAsync();

            //5. get a full graph of all courses
            //   order by the amount of student in course, descending
            var allStudentCourses = await schoolContext.Set <StudentCourse>() //start in the join table
                                    .Include(sc => sc.Course)
                                    .ThenInclude(c => c.Lecturer)
                                    .Include(sc => sc.Student)
                                    .ThenInclude(s => s.ContactInfo)
                                    .ToListAsync();

            //operations beyond this point happen in memory, not in database
            vm.Courses = allStudentCourses
                         .Select(sc => sc.Course)                           //select by Course, once results are in
                         .Distinct()                                        //select each course only once
                         .OrderByDescending(sc => sc.StudentCourses.Count); //order by number of StudentCourses

            return(View(vm));
        }