Exemplo n.º 1
0
        public async Task <IViewComponentResult> InvokeAsync(AdminViewModel model)
        {
            var _model = model ?? new AdminViewModel();

            _model.NewsletterSubscribersCount = _newsLetterRepository.GetNewsletters().Count();
            _model.ReadingsCount      = _horoscopeRepository.GetAll().Count();
            _model.SaturnReportsCount = _saturnReportRepository.GetAllSaturnReports().Count();


            return(View(_model));
        }
Exemplo n.º 2
0
        public IActionResult Index()
        {
            var model = new NewsletterViewModel();

            model.Newsletters = _newsletterRepository.GetNewsletters();

            //var items = from w in _warningRepository.GetWarnings().Where(x => (model.IsAllBrandsSelected == true || x.BrandId == model.BrandId))
            //            join b in _brandRepository.GetBrands() on w.BrandId equals b.Id
            //            select new WarningViewModel
            //   var model = from u in _customerRepository.GetAll().Where(x => x.FirstName == user.UserFirstname))

            return(View(model));
        }
Exemplo n.º 3
0
        // GET: Admin
        public async Task <ActionResult> Index()
        {
            int requestNumber = 5;
            var model         = new AdminViewModel();

            if (ModelState.IsValid)
            {
                var userId = _userManager.GetUserId(HttpContext.User);
                if (userId != null)
                {
                    ApplicationUser user = await _userManager.FindByIdAsync(userId);

                    if (await _userManager.IsInRoleAsync(user, "ADMIN"))
                    {
                        model.NewsletterSubscribersCount = _newsLetterRepository.GetNewsletters().Count();
                        model.SaturnReportsCount         = _saturnReportRepository.GetAllSaturnReports().Count();
                        model.ReadingsCount          = _horoscopeRepository.GetAll().Count();
                        model.Customers              = _customerRepository.GetAll();
                        model.SaturnReportsRequested = requestNumber;
                        model.SaturnReports          = _saturnReportRepository.GetAllSaturnReports();
                        model.CustomerList           = _customerRepository.GetAll()
                                                       .Select(x => new SelectListItem
                        {
                            Value = x.Id.ToString(),
                            Text  = x.UserName
                        }).ToList();
                        model.Customers = _customerRepository.GetAll();
                    }
                    else if (await _userManager.IsInRoleAsync(user, "USER"))
                    {
                        return(RedirectPermanent("Home/Index"));
                    }
                }
                else
                {
                    return(RedirectPermanent("/Pages/Account/Login"));
                }
            }
            return(View(model));
        }