public IActionResult Create(Task task) { if (ModelState.IsValid) { if (task.StartDate.Value > task.EndDate.Value) { ModelState.AddModelError("EndgtStart", "Date of End can't be earlier, then date of Start"); return(View()); } count++; _context.AddNewTask(task); if ((count - 1) % skip == 0 && count > skip) { pages = (count - 1) / skip + 1; } take = pages * skip == count ? skip : (skip - (pages * skip - count)); new_skip = (pages - 1) * skip; currentPage = pages; ViewBag.Tasks = _context.GetRange(take, new_skip); return(View("Index")); } return(View()); }