public ActionResult Search(String tag, String from, String to) { if (!ModelState.IsValid) { return(View("/")); } DateTime fromDate; DateTime toDate; if (from != null && tag == null && to == null) { if (!DateTime.TryParse((from), out fromDate)) { ModelState.AddModelError("", "Fecha incorrecta."); SetMessage("¡ Lamentablemente, la fecha introducida es incorrecta ! ", BootstrapAlertTypes.Danger); return(Redirect("/")); } var model = MagazineService.GetNewsesByDateNewses(fromDate); return(View(model)); } if (from != null && to != null && tag != null) { if (!DateTime.TryParse((from), out fromDate)) { ModelState.AddModelError("", "Fecha incorrecta."); SetMessage("¡ Lamentablemente, la fecha inicial introducida es incorrecta ! ", BootstrapAlertTypes.Danger); return(Redirect("/")); } if (!DateTime.TryParse((to), out toDate)) { ModelState.AddModelError("", "Fecha incorrecta."); SetMessage("¡ Lamentablemente, la fecha final introducida es incorrecta ! ", BootstrapAlertTypes.Danger); return(Redirect("/")); } var items = MagazineService.GetNewsByTagAndDateRange(tag, fromDate, toDate); return(View(items)); } var news = MagazineService.GetNewsByTag(tag, 7); return(View(news)); }