// GET: GetCheckIn public ActionResult Index() { int inst_id = Convert.ToInt32(Request.QueryString["inst_id"]); int visitid = Convert.ToInt32(Request.QueryString["visit_id"]); int custid = Convert.ToInt32(Request.QueryString["cust_id"]); string lat = Convert.ToString(Request.QueryString["lat"]); string lon = Convert.ToString(Request.QueryString["lon"]); string hr = Convert.ToString(Request.QueryString["hr"]); string fcha = Convert.ToString(Request.QueryString["fcha"]); int emo = Convert.ToInt32(Request.QueryString["emo"]); var succes = ""; using (AppDTEntities objDataContext = new AppDTEntities()) { try { VISITA_REGISTRO vISITA = new VISITA_REGISTRO(); // fields to be insert vISITA.inst_id = inst_id; vISITA.reg_lat = lat; vISITA.reg_lon = lon; vISITA.cust_id = custid; vISITA.reg_date = fcha; vISITA.reg_ini = hr; vISITA.reg_end = hr; vISITA.visi_id = visitid; vISITA.reg_status = 1; vISITA.reg_emo = 0; objDataContext.VISITA_REGISTRO.Add(vISITA); objDataContext.SaveChanges(); var result = from r in objDataContext.VISITA_ASSIGN where r.visi_id == visitid select r; // Get the first record from the result VISITA_ASSIGN vISITA_ASSIGN = result.First(); // Update the product name vISITA_ASSIGN.visi_status = 1; objDataContext.SaveChanges(); succes = "Ok"; } catch (Exception e) { succes = "NoOk"; } } return(Json(new { succes }, JsonRequestBehavior.AllowGet)); }
// GET: GetCheckOut public ActionResult Index() { int inst_id = Convert.ToInt32(Request.QueryString["inst_id"]); int visitid = Convert.ToInt32(Request.QueryString["visit_id"]); int custid = Convert.ToInt32(Request.QueryString["cust_id"]); string lat = Convert.ToString(Request.QueryString["lat"]); string lon = Convert.ToString(Request.QueryString["lon"]); string hr = Convert.ToString(Request.QueryString["hr"]); string fcha = Convert.ToString(Request.QueryString["fcha"]); int emo = Convert.ToInt32(Request.QueryString["emo"]); var succes = ""; using (AppDTEntities db = new AppDTEntities()) { try { var result = from r in db.VISITA_REGISTRO where r.visi_id == visitid select r; VISITA_REGISTRO vISITA_REGISTRO = result.First(); vISITA_REGISTRO.reg_end = hr; vISITA_REGISTRO.reg_emo = emo; db.SaveChanges(); //status var result2 = from r in db.VISITA_ASSIGN where r.visi_id == visitid select r; VISITA_ASSIGN vISITA_ASSIGN = result2.First(); vISITA_ASSIGN.visi_status = 2; db.SaveChanges(); succes = "Ok"; } catch (Exception e) { succes = "NoOk"; } } return(Json(new { succes }, JsonRequestBehavior.AllowGet)); }
public ActionResult Index() { int inst_id = Convert.ToInt32(Request.QueryString["inst_id"]); int visitid = Convert.ToInt32(Request.QueryString["visit_id"]); int custid = Convert.ToInt32(Request.QueryString["cust_id"]); string lat = Convert.ToString(Request.QueryString["lat"]); string lon = Convert.ToString(Request.QueryString["lon"]); string hr = Convert.ToString(Request.QueryString["hr"]); string fcha = Convert.ToString(Request.QueryString["fcha"]); int emo = Convert.ToInt32(Request.QueryString["emo"]); var succes = ""; var buscar = db.VISITA_REGISTRO.Where(a => a.inst_id == inst_id && a.reg_status == 8).ToList(); if (buscar.Count() == 0) { using (AppDTEntities objDataContext = new AppDTEntities()) { try { VISITA_REGISTRO vISITA = new VISITA_REGISTRO(); // fields to be insert vISITA.inst_id = inst_id; vISITA.reg_lat = lat; vISITA.reg_lon = lon; vISITA.cust_id = custid; vISITA.reg_date = fcha; vISITA.reg_ini = hr; vISITA.reg_end = hr; vISITA.visi_id = 100; vISITA.reg_status = 8; vISITA.reg_emo = 0; objDataContext.VISITA_REGISTRO.Add(vISITA); objDataContext.SaveChanges(); succes = "Ok"; } catch (Exception e) { succes = "NoOk"; } } } else { if (buscar[0].reg_emo == 1) { using (AppDTEntities objDataContext = new AppDTEntities()) { try { VISITA_REGISTRO vISITA = new VISITA_REGISTRO(); // fields to be insert vISITA.inst_id = inst_id; vISITA.reg_lat = lat; vISITA.reg_lon = lon; vISITA.cust_id = custid; vISITA.reg_date = fcha; vISITA.reg_ini = hr; vISITA.reg_end = hr; vISITA.visi_id = 100; vISITA.reg_status = 8; vISITA.reg_emo = 0; objDataContext.VISITA_REGISTRO.Add(vISITA); objDataContext.SaveChanges(); succes = "Ok"; } catch (Exception e) { succes = "NoOk"; } } } else { if (buscar[0].inst_id != 0) { int id = buscar[0].inst_id; var result2 = from r in db.VISITA_REGISTRO where r.inst_id == id && r.reg_status == 8 select r; VISITA_REGISTRO vISITA_ASSIGN = result2.First(); vISITA_ASSIGN.reg_end = hr; vISITA_ASSIGN.reg_emo = 1; db.SaveChanges(); succes = "Ok"; } else { using (AppDTEntities objDataContext = new AppDTEntities()) { try { VISITA_REGISTRO vISITA = new VISITA_REGISTRO(); // fields to be insert vISITA.inst_id = inst_id; vISITA.reg_lat = lat; vISITA.reg_lon = lon; vISITA.cust_id = custid; vISITA.reg_date = fcha; vISITA.reg_ini = hr; vISITA.reg_end = hr; vISITA.visi_id = 100; vISITA.reg_status = 8; vISITA.reg_emo = 0; objDataContext.VISITA_REGISTRO.Add(vISITA); objDataContext.SaveChanges(); succes = "Ok"; } catch (Exception e) { succes = "NoOk"; } } } } } return(Json(new { succes }, JsonRequestBehavior.AllowGet)); }