//public ActionResult Index(string usr, string Opt1, string CercaTarga, string SearchLocation) //{ // if (usr != null) // Session["User"] = usr; // if (usr == null) // usr = Session["User"].ToString(); // bool isAuth = false; // if (usr != String.Empty) // { // string UserName = ""; // string cookieName = FormsAuthentication.FormsCookieName; //Find cookie name // HttpCookie cookie = HttpContext.Request.Cookies[cookieName]; //Get the cookie by it's name // FormsAuthenticationTicket ticket = FormsAuthentication.Decrypt(cookie.Value); //Decrypt it // UserName = ticket.Name; //You have the UserName! // if (usr == UserName) // { // ViewBag.Messaggio = "BENE il cookie corrisponde!"; // //ViewBag.Messaggio = personaggio; // isAuth = true; // using (AUTOSDUEntities val = new AUTOSDUEntities()) // { // Session["Status"] = ""; // var fromDatabaseEF = new SelectList(val.Luoghi_vw.ToList(), "ID", "DescrITA"); // ViewData["Luoghi"] = fromDatabaseEF; // } // if (String.IsNullOrEmpty(CercaTarga)) // { // return View(); // } // else if (!String.IsNullOrEmpty(CercaTarga)) // { // var model = new Models.HomeModel(); // var telai = from s in db.AT_ListaPratiche_vw // where s.Targa.ToString() == CercaTarga // select s; // model.AT_ListaPratiche_vw = telai.ToList(); // return View("ElencoTelai", model); // } // else // { // return View(); // } // } // else // { // ViewBag.Messaggio = "il cookie contenente lo 'username' non corrisponde allo User della queryString!"; // isAuth = false; // return View("IncorrectLogin"); // } // } // else // { // string UserName = ""; // string cookieName = FormsAuthentication.FormsCookieName; //Find cookie name // HttpCookie cookie = HttpContext.Request.Cookies[cookieName]; //Get the cookie by it's name // FormsAuthenticationTicket ticket = FormsAuthentication.Decrypt(cookie.Value); //Decrypt it // UserName = ticket.Name; //You have the UserName! // } // return View(); //} public ActionResult Index(string Opt1, string CercaTarga, string SearchLocation) { using (AUTOSDUEntities val = new AUTOSDUEntities()) { Session["Status"] = ""; var fromDatabaseEF = new SelectList(val.Luoghi_vw.ToList(), "ID", "DescrITA"); ViewData["Luoghi"] = fromDatabaseEF; } if (String.IsNullOrEmpty(CercaTarga)) { return(View()); } else if (!String.IsNullOrEmpty(CercaTarga)) { var model = new Models.HomeModel(); var telai = from s in db.AT_ListaPratiche_vw where s.Targa.ToString() == CercaTarga select s; model.AT_ListaPratiche_vw = telai.ToList(); return(View("ElencoTelai", model)); } else { return(View()); } //return RedirectToAction("DoRefresh", "Home"); }
public ActionResult DoRefresh(string Opt1, string CercaTarga, string SearchLocation) { //string UserName = ""; //string cookieName = FormsAuthentication.FormsCookieName; //Find cookie name //HttpCookie cookie = HttpContext.Request.Cookies[cookieName]; //Get the cookie by it's name //FormsAuthenticationTicket ticket = FormsAuthentication.Decrypt(cookie.Value); //Decrypt it //UserName = ticket.Name; //You have the UserName! if (Opt1 != null) { Session["Status"] = Opt1; } else { Opt1 = Session["Status"].ToString(); } using (AUTOSDUEntities val = new AUTOSDUEntities()) { //Session["Scelta1"] = ""; var fromDatabaseEF = new SelectList(val.Luoghi_vw.ToList(), "ID", "DescrITA"); ViewData["Luoghi"] = fromDatabaseEF; } if (CercaTarga != null && CercaTarga != "") { Session["TipoRicerca"] = "MONO"; var IsInserted = (from s in db.AT_ListaPratiche_vw where s.Targa.ToString() == CercaTarga select s.Perizie_ID).Count(); if (IsInserted > 0) { try { var IsClosed = (from s in db.AT_ListaPratiche_vw where s.Targa.ToString() == CercaTarga select s.IsCompleted).FirstOrDefault(); if (IsClosed.Value == false) { Session["Status"] = "FATTE"; } else { Session["Status"] = "FATTECHIUSE"; } } catch { Session["Status"] = "DA FARE"; } } else { Session["Status"] = "DA FARE"; } var model = new Models.HomeModel(); var telai = from s in db.AT_ListaPratiche_vw where s.Targa.ToString() == CercaTarga select s; model.AT_ListaPratiche_vw = telai.ToList(); return(View("ElencoTelai", model)); } else if (Opt1 == "TUTTE") { var model = new Models.HomeModel(); var telai = from s in db.AT_ListaPratiche_vw //where s.ID_LuogoIntervento == SearchLocation select s; model.AT_ListaPratiche_vw = telai.ToList(); return(View("ElencoTelai", model)); } else if (Opt1 == "DA FARE") { var model = new Models.HomeModel(); var telai = from s in db.AT_ListaPratiche_vw where s.ID_SchedaTecnica == null //where s.ID_LuogoIntervento == SearchLocation select s; model.AT_ListaPratiche_vw = telai.ToList(); return(View("ElencoTelai", model)); } else if (Opt1 == "FATTE") { var model = new Models.HomeModel(); var telai = from s in db.AT_ListaPratiche_vw where s.ID_SchedaTecnica != null where s.IsCompleted == false //where s.ID_LuogoIntervento == SearchLocation select s; model.AT_ListaPratiche_vw = telai.ToList(); return(View("ElencoTelai", model)); } else if (Opt1 == "FATTECHIUSE") { var model = new Models.HomeModel(); var telai = from s in db.AT_ListaPratiche_vw where s.ID_SchedaTecnica != null where s.IsCompleted == true //where s.ID_LuogoIntervento == SearchLocation select s; model.AT_ListaPratiche_vw = telai.ToList(); return(View("ElencoTelai", model)); } else { return(View("Index")); } }