public ActionResult Contacts(string a, string u) { if (Session["username"] != null) { if (a == null && u == null) { String usertag = Session["username"].ToString(); var userid = Int32.Parse(Session["userId"].ToString()); cl1 = dbnew.contacts1.Where(x => x.uid == userid).ToList(); // cl1 = db.contacts1.ToList(); cl1 = cl1.OrderBy(x => x.firstName).ToList(); for (int i = 0; i < cl1.Count; i++) { cl1[i].firstName = char.ToUpper(cl1[i].firstName[0]) + cl1[i].firstName.Substring(1); } alpha = c.getalphabetsnewdb(cl1); ft1new = c.getallftag(userid); lt1 = c.getallctag(userid); contactandtags ct = new contactandtags(lt1, ft1new, cl1, alpha); return(View(ct)); } else if (a != null && u == null) { var userid = Int32.Parse(Session["userId"].ToString()); ft1new = c.getallftag(userid); lt1 = c.getallctag(userid); cl1 = dbnew.contacts1.Where(x => x.uid == userid).ToList(); // cl1 = db.contacts1.ToList(); cl1 = cl1.OrderBy(x => x.firstName).ToList(); for (int i = 0; i < cl1.Count; i++) { cl1[i].firstName = char.ToUpper(cl1[i].firstName[0]) + cl1[i].firstName.Substring(1); } alpha = c.getalphabetsnewdb(cl1); ct = new contactandtags(lt1, ft1new, cl1, alpha); return(View(ct)); } else if (a == null && u != null) { var userid = Int32.Parse(Session["userId"].ToString()); ft1new = c.getallftag(userid); lt1 = c.getallctag(userid); String usertag = Session["username"].ToString(); List <Contact> cl = new List <Contact>(); cl1 = dbnew.contacts1.Where(x => x.uid == userid).ToList(); // cl1 = db.contacts1.ToList(); cl1 = cl1.OrderBy(x => x.firstName).ToList(); for (int i = 0; i < cl1.Count; i++) { cl1[i].firstName = char.ToUpper(cl1[i].firstName[0]) + cl1[i].firstName.Substring(1); } alpha = c.getalphabetsnewdb(cl1); contactandtags ct = new contactandtags(lt1, ft1new, cl1, alpha); return(View(ct)); } else { var userid = Int32.Parse(Session["userId"].ToString()); ft1new = c.getallftag(userid); lt1 = c.getallctag(userid); String usertag = Session["username"].ToString(); cl1 = dbnew.contacts1.Where(x => x.uid == userid).ToList(); // cl1 = db.contacts1.ToList(); cl1 = cl1.OrderBy(x => x.firstName).ToList(); for (int i = 0; i < cl1.Count; i++) { cl1[i].firstName = char.ToUpper(cl1[i].firstName[0]) + cl1[i].firstName.Substring(1); } alpha = c.getalphabetsnewdb(cl1); contactandtags ct = new contactandtags(lt1, ft1new, cl1, alpha); return(View(ct)); } } else { return(RedirectToAction("Index", "Home")); } }