public ActionResult Index(string lstSubject, string lstImportance, string radio, DateTime?searchDate = null) { try { List <complaint> lst = new List <complaint>(); List <ComplaintViewModel> ll = new List <ComplaintViewModel>(); if (radio.Equals("sujet")) { lst = cs.complaintsBySubject(lstSubject).ToList(); } else if (radio.Equals("importance")) { lst = cs.complaintsByImportance(lstImportance).ToList(); } else if (radio.Equals("day") && searchDate != null) { lst = cs.ComplaintsByDay((DateTime)searchDate).ToList(); } else if (radio.Equals("month") && searchDate != null) { lst = cs.complaintsByMonth((DateTime )searchDate).ToList(); } foreach (complaint comp in lst) { ComplaintViewModel cm = new ComplaintViewModel(); cm.id = comp.id; cm.Description = comp.Description; cm.creationDate = comp.creationDate; cm.Subject = comp.Subject; cm.importanceLvl = comp.importanceLvl; cm.MyUser_idUser = (int)comp.MyUser_idUser; cm.user = us.GetById((int)comp.MyUser_idUser); ll.Add(cm); } return(View(ll)); }catch { return(View()); } }