// GET: Task public ActionResult Index(DateTime?id) { if (id.HasValue) { var tasksByDate = tasksService.GetAllBy(id.Value); return(View(tasksByDate)); } else if (Request.Form["date"] != null) { try { var tasksByDate = tasksService.GetAllBy(Convert.ToDateTime(Request.Form["date"])); return(View(tasksByDate)); } catch { return(RedirectToAction("Index")); } } else if (Request.Form["Content"] != null) { try { var tasksByText = tasksService.GetAllByText(Convert.ToString(Request.Form["Content"])); return(View(tasksByText)); } catch { return(RedirectToAction("Index")); } } var tasks = tasksService.GetAll(); return(View(tasks)); }