public ActionResult BatchDelete(FilterViewModel filterParams, string message)
        {
            ApplicationUser user = applicationUserService.GetApplicationUserById(User.Identity.GetUserId());

            if (user == null)
            {
                return new HttpStatusCodeResult(HttpStatusCode.Unauthorized);
            }

            filterParams.Email = user.Email;
            var activityData = dataService.Filter(filterParams);
            dataService.BatchDelete(activityData, message, user.Id);
            return RedirectToAction("Index");
        }
        public ActionResult ConfirmBatchDelete(int? page, FilterViewModel filterParams)
        {
            string userId = User.Identity.GetUserId();
            ApplicationUser user = db.Users.Where(u => u.Id.Equals(userId)).Single();

            if (user == null)
            {
                return new HttpStatusCodeResult(HttpStatusCode.Unauthorized);
            }

            filterParams.Email = user.Email;
            var activityData = dataService.Filter(filterParams);
            filterParams.Size = activityData.Count();
            return View("BatchDelete", filterParams);
        }
        public ActionResult BatchDelete(FilterViewModel filterParams, string message)
        {
            string userId = User.Identity.GetUserId();
            ApplicationUser user = db.Users.Where(u => u.Id.Equals(userId)).Single();

            if (user == null)
            {
                return new HttpStatusCodeResult(HttpStatusCode.Unauthorized);
            }

            filterParams.Email = user.Email;
            var activityData = dataService.Filter(filterParams);
            dataService.BatchDelete(activityData, message, userId);
            return RedirectToAction("Manage");
        }
        public ActionResult Manage(int? page, FilterViewModel filterParams)
        {
            string userId = User.Identity.GetUserId();
            ApplicationUser user = db.Users.Where(u => u.Id.Equals(userId)).Single();

            if (user == null)
            {
                return new HttpStatusCodeResult(HttpStatusCode.Unauthorized);
            }

            filterParams.Email = user.Email;
            var activityData = dataService.Filter(filterParams);
            int pageNumber = (page ?? 1);

            var categories = categoryUnitService.CreateCategoryUnitList();
            ViewBag.categoryUnits = new SelectList(categories, "idCategoryUnit", "unit", "category", 0);

            ActivityDataListViewModel model = new ActivityDataListViewModel();
            model.Data = activityData.ToPagedList(pageNumber, pageSize);
            model.FilterParams = filterParams;
            //note: must manually redirect view here because of the MultipleButton annotation.
            return View("Manage", model);
        }
Beispiel #5
0
        public IQueryable<ActivityData> Filter(FilterViewModel filterParams)
        {
            var activityData = GetAllActivityData();
            if (!String.IsNullOrEmpty(filterParams.Email))
            {
                activityData = activityData.Where(a => a.User.Email.Contains(filterParams.Email));
            }

            if (filterParams.CategoryUnitId > 0)
            {
                activityData = activityData.Where(a => a.categoryunit.Id == filterParams.CategoryUnitId);
            }

            if (filterParams.FromDate.HasValue)
            {
                activityData = activityData.Where(a => a.date >= filterParams.FromDate.Value);
            }

            if (filterParams.ToDate.HasValue)
            {
                activityData = activityData.Where(a => a.date <= filterParams.ToDate.Value);
            }

            return activityData;
        }
 public ActionResult ConfirmBatchDelete(int? page, FilterViewModel filterParams)
 {
     var activityData = dataService.Filter(filterParams);
     filterParams.Size = activityData.Count();
     return View("BatchDelete", filterParams);
 }
        public ActionResult Index(int? page, FilterViewModel filterParams)
        {
            var activityData = dataService.Filter(filterParams);
            int pageNumber = (page ?? 1);

            var categories = categoryUnitService.CreateCategoryUnitList();
            ViewBag.categoryUnits = new SelectList(categories, "idCategoryUnit", "unit", "category", 0);

            ActivityDataListViewModel model = new ActivityDataListViewModel();
            model.Data = activityData.ToPagedList(pageNumber, pageSize);
            model.FilterParams = filterParams;
            return View("Index", model);
        }