// GET api/values/5 public HttpResponseMessage Get(int id, string dataBase = "DefaultConnection") { HttpResponseMessage response; try { using (var db = new SqlConnection(ConfigurationManager.ConnectionStrings[dataBase].ConnectionString)) { var cmd = new SqlCommand("SELECT * FROM AGENT_CAMP where ACTIVE_SW = 1 and END_DATE is null and AGENT_CAMP_ID = " + id, db); var agent = new AGENT_CAMP(); db.Open(); using (var rdr = cmd.ExecuteReader()) { while (rdr.Read()) { agent = BuildAgentObject(rdr); } } var result = agent; response = Request.CreateResponse(HttpStatusCode.OK); response.Content = new StringContent(JsonConvert.SerializeObject(result)); } } catch (Exception ex) { response = Request.CreateResponse(HttpStatusCode.InternalServerError); response.Content = new StringContent(JsonConvert.SerializeObject(ex)); } return(response); }
public ActionResult DeleteConfirmed(int id) { AGENT_CAMP agent_camp = db.AGENT_CAMP.Find(id); db.AGENT_CAMP.Remove(agent_camp); db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Edit(AGENT_CAMP agent_camp) { if (ModelState.IsValid) { db.Entry(agent_camp).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(agent_camp)); }
// // GET: /AddAgent/Edit/5 public ActionResult Edit(int id = 0) { AGENT_CAMP agent_camp = db.AGENT_CAMP.Find(id); if (agent_camp == null) { return(HttpNotFound()); } return(View(agent_camp)); }
// PUT api/values/5 public HttpResponseMessage Put(int id, [FromBody] AGENT_CAMP value, string dataBase = "DefaultConnection") { HttpResponseMessage response; try { using (var db = new SqlConnection(ConfigurationManager.ConnectionStrings[dataBase].ConnectionString)) using (var command = db.CreateCommand()) { command.CommandText = "UPDATE a SET " + (value.END_DATE != null ? "END_DATE = '" + value.END_DATE + "', ACTIVE_SW =0, " : "") + (value.MIN_RECORDS != null ? "MIN_RECORDS = " + value.MIN_RECORDS + "," : "") + (value.MAX_RECORDS != null ? "MAX_RECORDS = " + value.MAX_RECORDS + "," : "") + (value.workgroup != null ? "workgroup = '" + value.workgroup + "'," : "") + (value.Phone_Number != null ? "Phone_Number = '" + value.Phone_Number + "'," : "") + (value.BAM_EMAIL != null ? "BAM_EMAIL = '" + value.BAM_EMAIL + "'," : "") + (value.DNIS != null ? "DNIS = '" + value.DNIS + "'," : "") + (value.COMMUNICATOR != null ? "COMMUNICATOR = '" + value.COMMUNICATOR + "'," : "") + (value.CALLER_ID != null ? "CALLER_ID = '" + value.CALLER_ID + "'," : "") + (value.ORDER_MANAGER_SW != null ? "ORDER_MANAGER_SW = " + value.ORDER_MANAGER_SW + "," : "") + (value.NT_LOGIN_NAME != null ? "NT_LOGIN_NAME = '" + value.NT_LOGIN_NAME + "'" : "") + " FROM AGENT_CAMP a WHERE AGENT_CAMP_ID = " + id; //command.Parameters.AddWithValue("@END", value.END_DATE); //command.Parameters.AddWithValue("@Min", value.MIN_RECORDS); //command.Parameters.AddWithValue("@Max", value.MAX_RECORDS); //command.Parameters.AddWithValue("@workgroup", value.workgroup); //command.Parameters.AddWithValue("@Phone", value.Phone_Number); //command.Parameters.AddWithValue("@Email", value.BAM_EMAIL); //command.Parameters.AddWithValue("@DNIS", value.DNIS); //command.Parameters.AddWithValue("@Comm", value.COMMUNICATOR); //command.Parameters.AddWithValue("@CallerId", value.CALLER_ID); //command.Parameters.AddWithValue("@OM", value.ORDER_MANAGER_SW); //command.Parameters.AddWithValue("@NT", value.NT_LOGIN_NAME); db.Open(); var testResult = command.ExecuteNonQuery(); response = Request.CreateResponse(HttpStatusCode.OK); response.Content = new StringContent(JsonConvert.SerializeObject(testResult)); } } catch (Exception ex) { response = Request.CreateResponse(HttpStatusCode.InternalServerError); response.Content = new StringContent(JsonConvert.SerializeObject(ex)); } return(response); }
public ActionResult Create(AGENT_CAMP agent_camp) { if (ModelState.IsValid) { agent_camp.CAMP_ABBR = "CMCB0001"; agent_camp.ACTIVE_SW = true; agent_camp.ALWAYS_FILL_BOOK_OF_BUSINESS_SW = true; agent_camp.REGION = "Northeast"; agent_camp.REGION_ID = 1; agent_camp.TEST_AGENT = false; db.AGENT_CAMP.Add(agent_camp); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(agent_camp)); }
// POST api/values public void Post([FromBody] AGENT_CAMP value) { }