Exemplo n.º 1
0
        public ActionResult Search(SearchModel model)
        {
            try
            {
                IEnumerable<Model.RepairCard> cards = null;
                if (!string.IsNullOrEmpty(model.RegistrationNumber))
                {
                    cards = RepairsManager.GetManager().Get()
                        .Where(x => x.Car.RegistrationNumber.Contains(model.RegistrationNumber));

                }
                if (!string.IsNullOrEmpty(model.FrameNumber))
                {
                    cards =  RepairsManager.GetManager().Get()
                        .Where(x => x.Car.FrameNumber.Contains(model.FrameNumber));
                }

                var cardsModel = MappingManager.Instance.Map<IEnumerable<Model.RepairCard>, IEnumerable<RepairCardModel>>(cards);

                var pageModel = new PagingModel(cardsModel.Count());
                pageModel.ItemsOnPage = 15;
                pageModel.PageNumber = 1;
                pageModel.PageContent = cardsModel;

                return View("~/Views/Repairs/Index.cshtml", pageModel);
            }
            catch (Exception ex)
            {
                return View(model);
            }
        }
Exemplo n.º 2
0
        //
        // GET: /Users/
        public ActionResult Index(int page = 1)
        {
            int usersCount;
            var users = Membership.GetAllUsers(page-1, UsersController.ItemsOnPage, out usersCount);

            var model = new PagingModel(usersCount);
            model.ItemsOnPage = UsersController.ItemsOnPage;
            model.PageNumber = page;
            model.PageContent = users;

            return View(model);
        }
        //
        // GET: /Mechanics/
        public ActionResult Index(int page = 1)
        {
            var items = MechanicsManager.GetManager().Get();
            var mapped = MappingManager.Instance.Map<IEnumerable<Core.Model.Mechanic>, IEnumerable<MechanicModel>>(items);

            var model = new PagingModel(items.Count());
            model.ItemsOnPage = 15;
            model.PageNumber = page;
            model.PageContent = mapped.Skip(model.SkippedNumber).Take(model.ItemsOnPage);

            return View(model);
        }
Exemplo n.º 4
0
        //
        // GET: /Repairs/
        public ActionResult Index(string status = "Personal", int page = 1)
        {
            PagingModel model = null;
            var repairCards = RepairsManager.GetManager().Get();
            var repairCardsModel = MappingManager.Instance.Map<IEnumerable<Core.Model.RepairCard>, IEnumerable<RepairCardModel>>(repairCards);

            switch (status)
            {
                case "All":
                    model = new PagingModel(repairCardsModel.Count());
                    model.ItemsOnPage = RepairsController.ItemsOnPage;
                    model.PageNumber = page;
                    model.PageContent = repairCardsModel.Skip(model.SkippedNumber).Take(model.ItemsOnPage);
                    ViewBag.Status = "All";
                    break;
                case "InProgress":
                    model = new PagingModel(repairCardsModel.Where(c => !c.Completed).Count());
                    model.ItemsOnPage = RepairsController.ItemsOnPage;
                    model.PageNumber = page;
                    model.PageContent = repairCardsModel.Where(x => !x.Completed).Skip(model.SkippedNumber).Take(model.ItemsOnPage);
                    ViewBag.Status = "InProgress";
                    break;
                case "Completed":
                    model = new PagingModel(repairCardsModel.Where(c => c.Completed).Count());
                    model.ItemsOnPage = RepairsController.ItemsOnPage;
                    model.PageNumber = page;
                    model.PageContent = repairCardsModel.Where(x => x.Completed).Skip(model.SkippedNumber).Take(model.ItemsOnPage);
                    ViewBag.Status = "Completed";
                    break;
                case "Personal":
                    var userGUID = (Guid)Membership.GetUser(User.Identity.Name).ProviderUserKey;
                    var items = repairCardsModel.Where(x => x.UserId.Equals(userGUID));
                    model = new PagingModel(items.Count());
                    model.ItemsOnPage = RepairsController.ItemsOnPage;
                    model.PageNumber = page;
                    model.PageContent = items.Skip(model.SkippedNumber).Take(model.ItemsOnPage);
                    ViewBag.Status = "Personal";
                    break;
                default:
                    break;
            }

            return View(model);
        }
Exemplo n.º 5
0
        //
        // GET: /Parts/
        public ActionResult Index(int page = 1)
        {
            var model = new PagingModel(SparePartsManager.GetInstance().Count());
            model.ItemsOnPage = 15;
            model.PageNumber = page;
            model.PageContent = SparePartsManager.GetInstance().GetAll<PartModel>().Skip(model.SkippedNumber).Take(model.ItemsOnPage);

            return View(model);
        }