protected void btnInsert_Click(object sender, EventArgs e) { try { progDec = new ProgDec(); progDec.ProgramId = programs[ddlPrograms.SelectedIndex].Id; progDec.StudentId = students[ddlStudents.SelectedIndex].Id; int results = ProgDecManager.Insert(progDec); Response.Write("Inserted " + results + " rows."); progDecs.Add(progDec); Rebind(); if (results > 0) { ddlChangeDate.SelectedValue = progDec.Id.ToString(); } ddlChangeDate_SelectedIndexChanged(sender, e); } catch (Exception ex) { Response.Write(ex.Message); } }
public void UpdateTest() { ProgDec progDec = ProgDecManager.LoadById(6); progDec.ProgramId = 13; Assert.IsTrue(ProgDecManager.Update(progDec) > 0); }
public ActionResult Insert() { HttpClient client = InitializeClient(); ProgDec progDec = new ProgDec(); return(View("Create", progDec)); }
public void InsertTest() { ProgDec progDec = new ProgDec { ProgramId = 12, StudentId = 4 }; Assert.AreNotEqual(0, ProgDecManager.Insert(progDec)); }
public ActionResult Remove(int id) { HttpClient client = InitializeClient(); HttpResponseMessage response = client.GetAsync("ProgDec/" + id).Result; string result = response.Content.ReadAsStringAsync().Result; ProgDec progDec = JsonConvert.DeserializeObject <ProgDec>(result); return(View("Delete", progDec)); }
public void InsertTest() { ProgDec progdec = new ProgDec(); progdec.ChangeDate = DateTime.Now; progdec.StudentId = -99; progdec.ProgramId = 4; bool result = progdec.Insert(); Assert.IsTrue(result); }
public ActionResult Remove(int id, ProgDec progDec) { try { HttpClient client = InitializeClient(); HttpResponseMessage response = client.DeleteAsync("ProgDec/" + id).Result; return(RedirectToAction("Get")); } catch (Exception ex) { ViewBag.Error = ex.Message; return(View("Delete", progDec)); } }
public ActionResult Update(ProgDec progDec, int id) { try { HttpClient client = InitializeClient(); HttpResponseMessage response = client.PutAsJsonAsync("ProgDec/" + id, progDec).Result; return(RedirectToAction("Get")); } catch (Exception ex) { ViewBag.Error = ex.Message; return(View("Edit", progDec)); } }
public ActionResult Insert(ProgDec progDec) { try { HttpClient client = InitializeClient(); HttpResponseMessage response = client.PostAsJsonAsync("ProgDec", progDec).Result; return(RedirectToAction("Get")); } catch (Exception ex) { ViewBag.Error = ex.Message; return(View("Create", progDec)); } }
public void DeleteTest() { ProgDec progDec = new ProgDec(); ProgDecList progDecs = new ProgDecList(); progDecs.Load(); progDec = progDecs.Where(p => p.StudentId == -99).FirstOrDefault(); int result = progDec.Delete(); Assert.IsTrue(result > 0); }
public ActionResult GetOne(int id) { HttpClient client = InitializeClient(); //Do the actual call to the WebAPI HttpResponseMessage response = client.GetAsync("ProgDec/" + id).Result; //Parse the result string result = response.Content.ReadAsStringAsync().Result; //Parse the result into generic objects ProgDec progDec = JsonConvert.DeserializeObject <ProgDec>(result); return(View("Details", progDec)); }
public static int Insert(ProgDec progDec) { try { int id = 0; int result = Insert(out id, progDec.ProgramId, progDec.StudentId); progDec.Id = id; return(result); } catch (Exception ex) { throw ex; } }
protected void btnDelete_Click(object sender, EventArgs e) { try { progDec = progDecs[ddlChangeDate.SelectedIndex]; int results = ProgDecManager.Update(progDec); Response.Write("Updated " + results + " rows."); progDecs.Remove(progDec); Rebind(); ddlChangeDate_SelectedIndexChanged(sender, e); } catch (Exception ex) { Response.Write(ex.Message); } }
public void UpdateTest() { ProgDec progDec = new ProgDec(); ProgDecList progDecs = new ProgDecList(); progDecs.Load(); progDec = progDecs.Where(p => p.StudentId == -99).FirstOrDefault(); progDec.ProgramId = 5; progDec.Update(); ProgDec updatedProgDec = new ProgDec(); updatedProgDec.Id = progDec.Id; updatedProgDec.LoadById(); Assert.AreEqual(progDec.ProgramId, updatedProgDec.ProgramId); }
protected void ddlChangeDate_SelectedIndexChanged(object sender, EventArgs e) { progDec = progDecs[ddlChangeDate.SelectedIndex]; ddlStudents.SelectedValue = progDec.StudentId.ToString(); ddlPrograms.SelectedValue = progDec.ProgramId.ToString(); }
public static int Update(ProgDec progDec) { return(Update(progDec.Id, progDec.ProgramId, progDec.StudentId)); }