Esempio n. 1
0
        public ActionResult chargesList(int page = 1)
        {
            if (!authorize())
            {
                return(new HttpStatusCodeResult(System.Net.HttpStatusCode.Unauthorized));
            }
            var model = new ViewModels.PaginatedViewModel <Charge>();

            model.modelList      = context.Charge.OrderByDescending(d => d.chargeId).Skip((page - 1) * pageSize).Take(pageSize).ToList();
            model.pagingInfo     = new ViewModels.PageInfo(context.Charge.Count(), pageSize, page);
            ViewBag.totalCharges = context.Charge.Count();

            if (context.Charge.Count() > 0)
            {
                ViewBag.totalPaid     = context.Charge.Where(c => c.amountPaid != null).Sum(c => c.amountPaid);
                ViewBag.totalResolved = context.Charge.Where(i => i.isResolved).Count();
                ViewBag.totalUnpaid   = context.Charge.Sum(c => c.amountCharged) - ViewBag.totalPaid;
            }
            else
            {
                ViewBag.totalPaid     = 0;
                ViewBag.totalResolved = 0;
                ViewBag.totalUnpaid   = 0;
            }
            return(View(model));
        }
Esempio n. 2
0
        /// <summary>
        /// ////////////////////////////////////////////////////////////////////////////////////////////////////////////
        /// ////////////////////////////////////////////////////////////////////////////////////////////////////////////
        /// </summary>
        /// <param name="bikeId"></param>
        /// <param name="page"></param>
        /// <returns></returns>
        public ActionResult bikeCheckouts(int?rackId, int?bikeID, int page = 1)
        {
            if (!authorize())
            {
                return(new HttpStatusCodeResult(System.Net.HttpStatusCode.Unauthorized));
            }
            var model = new ViewModels.PaginatedViewModel <CheckOut>();

            IQueryable <CheckOut> list;

            if (bikeID == null && rackId == null)
            {
                list = context.CheckOut;
            }
            else if (rackId != null)
            {
                list = context.CheckOut.Where(u => u.rackCheckedOut == rackId || u.rackCheckedIn == rackId);
            }
            else
            {
                list = context.CheckOut.Where(b => b.bike == bikeID);
            }
            int total = list.Count();

            model.modelList  = list.OrderByDescending(d => d.timeOut).Skip((page - 1) * pageSize).Take(pageSize).ToList();
            model.pagingInfo = new ViewModels.PageInfo(total, pageSize, page);
            return(View(model));
        }
Esempio n. 3
0
        public ActionResult userList(string name = "", int page = 1, bool?hasCharges = null, bool?hasBike = null, bool?canMaintain = null, bool?canAdmin = null, bool?canRide = null, bool?canCheckout = null)
        {
            if (!authorize())
            {
                return(new HttpStatusCodeResult(System.Net.HttpStatusCode.Unauthorized));
            }

            List <bikeUser> baseList = new List <bikeUser>();

            if (hasCharges.HasValue && hasCharges.Value)
            {
                baseList = context.Charge.Where(r => !r.isResolved).Select(u => u.user).ToList();
            }
            if (hasBike.HasValue && hasBike.Value)
            {
                var userIds = context.CheckOut.Where(r => !r.isResolved).Select(u => u.rider).ToList();
                userIds.ForEach(u => baseList.Add(context.BikeUser.Find(u)));
            }

            if (canMaintain.HasValue && canMaintain.Value)
            {
                baseList = context.BikeUser.Where(c => c.canMaintainBikes).ToList();
            }
            if (canAdmin.HasValue && canAdmin.Value)
            {
                baseList = context.BikeUser.Where(c => c.canAdministerSite).ToList();
            }
            if (canRide.HasValue && canRide.Value)
            {
                baseList = context.BikeUser.Where(c => !c.canBorrowBikes).ToList();
            }
            if (canCheckout.HasValue && canCheckout.Value)
            {
                baseList = context.BikeUser.Where(c => c.canCheckOutBikes).ToList();
            }
            if (!String.IsNullOrWhiteSpace(name))
            {
                baseList = context.BikeUser.Where(c => c.userName.Contains(name)).ToList();
                baseList.AddRange(context.BikeUser.Where(c => c.firstName.Contains(name)).ToList());
                baseList.AddRange(context.BikeUser.Where(c => c.lastName.Contains(name)).ToList());
            }
            int totalResults = baseList.Count();
            var model        = new ViewModels.PaginatedViewModel <ViewModels.Admin.AdminUserVM>(totalResults, 25);

            baseList = baseList.OrderByDescending(d => d.userName).Skip((page - 1) * pageSize).Take(pageSize).ToList();

            model.modelList = new List <ViewModels.Admin.AdminUserVM>();
            foreach (var user in baseList)
            {
                model.modelList.Add(new ViewModels.Admin.AdminUserVM {
                    Email    = user.email, FirstName = user.firstName,
                    LastName = user.lastName, IsArchived = user.isArchived, UserName = user.userName, Id = user.bikeUserId,
                    RegistrationPDFNumber = user.registrationPDFNumber, Phone = user.phoneNumber,
                    LastRegistered        = user.lastRegistered.Year < 2014 ? null : (System.Nullable <DateTime>)user.lastRegistered
                });
            }
            return(View(model));
        }
        public ActionResult userList(string name = "", int page = 1, bool? hasCharges = null, bool? hasBike = null, bool? canMaintain = null, bool? canAdmin = null, bool? canRide = null, bool? canCheckout = null)
        {
            if (!authorize()) { return new HttpStatusCodeResult(System.Net.HttpStatusCode.Unauthorized); }

            List<bikeUser> baseList = new List<bikeUser>();
            if(hasCharges.HasValue && hasCharges.Value)
            {
                baseList = context.Charge.Where(r => !r.isResolved).Select(u => u.user).ToList();
            }
            if(hasBike.HasValue && hasBike.Value)
            {
                var userIds = context.CheckOut.Where(r => !r.isResolved).Select(u => u.rider).ToList();
                userIds.ForEach(u => baseList.Add(context.BikeUser.Find(u)));
            }

            if(canMaintain.HasValue && canMaintain.Value)
            {
                baseList = context.BikeUser.Where(c => c.canMaintainBikes).ToList();
            }
            if(canAdmin.HasValue && canAdmin.Value)
            {
                baseList = context.BikeUser.Where(c => c.canAdministerSite).ToList();
            }
            if(canRide.HasValue && canRide.Value)
            {
                baseList = context.BikeUser.Where(c => !c.canBorrowBikes).ToList();
            }
            if(canCheckout.HasValue && canCheckout.Value)
            {
                baseList = context.BikeUser.Where(c => c.canCheckOutBikes).ToList();
            }
            if(!String.IsNullOrWhiteSpace(name))
            {
                baseList = context.BikeUser.Where(c => c.userName.Contains(name)).ToList();
                baseList.AddRange(context.BikeUser.Where(c => c.firstName.Contains(name)).ToList());
                baseList.AddRange(context.BikeUser.Where(c => c.lastName.Contains(name)).ToList());
            }
            int totalResults = baseList.Count();
            var model = new ViewModels.PaginatedViewModel<ViewModels.Admin.AdminUserVM>(totalResults, 25);
            baseList = baseList.OrderByDescending(d => d.userName).Skip((page - 1) * pageSize).Take(pageSize).ToList();

            model.modelList = new List<ViewModels.Admin.AdminUserVM>();
            foreach (var user in baseList)
            {
                model.modelList.Add(new ViewModels.Admin.AdminUserVM { Email = user.email, FirstName = user.firstName,
                    LastName = user.lastName, IsArchived = user.isArchived, UserName = user.userName, Id = user.bikeUserId,
                    RegistrationPDFNumber = user.registrationPDFNumber, Phone = user.phoneNumber,
                    LastRegistered = user.lastRegistered.Year < 2014 ? null : (System.Nullable<DateTime>)user.lastRegistered });
            }
            return View(model);
        }
        public ActionResult chargesList(int page = 1)
        {
            if (!authorize()) { return new HttpStatusCodeResult(System.Net.HttpStatusCode.Unauthorized); }
            var model = new ViewModels.PaginatedViewModel<Charge>();
            model.modelList = context.Charge.OrderByDescending(d => d.chargeId).Skip((page - 1) * pageSize).Take(pageSize).ToList();
            model.pagingInfo = new ViewModels.PageInfo(context.Charge.Count(), pageSize, page);
            ViewBag.totalCharges = context.Charge.Count();

            if(context.Charge.Count() > 0)
            {
                ViewBag.totalPaid = context.Charge.Where(c => c.amountPaid != null).Sum(c => c.amountPaid);
                ViewBag.totalResolved = context.Charge.Where(i => i.isResolved).Count();
                ViewBag.totalUnpaid = context.Charge.Sum(c => c.amountCharged) - ViewBag.totalPaid;
            }
            else
            {
                ViewBag.totalPaid = 0;
                ViewBag.totalResolved = 0;
                ViewBag.totalUnpaid = 0;
            }
            return View(model);
        }
        /// <summary>
        /// ////////////////////////////////////////////////////////////////////////////////////////////////////////////
        /// ////////////////////////////////////////////////////////////////////////////////////////////////////////////
        /// </summary>
        /// <param name="bikeId"></param>
        /// <param name="page"></param>
        /// <returns></returns>
        public ActionResult bikeCheckouts(int? rackId, int? bikeID, int page = 1)
        {
            if (!authorize()) { return new HttpStatusCodeResult(System.Net.HttpStatusCode.Unauthorized); }
            var model = new ViewModels.PaginatedViewModel<CheckOut>();

            IQueryable<CheckOut> list;
            if (bikeID == null && rackId == null)
            {
                list = context.CheckOut;
            }
            else if (rackId != null)
            {
                list = context.CheckOut.Where(u => u.rackCheckedOut == rackId || u.rackCheckedIn == rackId);
            }
            else
            {
                list = context.CheckOut.Where(b => b.bike == bikeID);
            }
            int total = list.Count();
            model.modelList = list.OrderByDescending(d => d.timeOut).Skip((page - 1) * pageSize).Take(pageSize).ToList();
            model.pagingInfo = new ViewModels.PageInfo(total, pageSize, page);
            return View(model);
        }