Exemplo n.º 1
0
        public async Task <ActionResult> Index(int page = 0)
        {
            ITamagotchiRepository repo = GetRepo();

            int per_page = await repo.TamagotchiPerPageAsync();

            int all_count = await repo.TamagotchiCountAsync();

            int page_num = (int)Math.Ceiling(all_count / (double)per_page);

            if (page > page_num)
            {
                page = page_num;
            }

            if (page < 0)
            {
                page = 0;
            }

            var tamagotchiContract = await repo.GetAllAsync(per_page *page);

            var param = new TamagotchiOverviewModel(tamagotchiContract, page, page_num);

            return(View(param));
        }