コード例 #1
0
        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);
            }
        }
コード例 #2
0
ファイル: utProgDec.cs プロジェクト: Parker-Student/ProgDec
        public void UpdateTest()
        {
            ProgDec progDec = ProgDecManager.LoadById(6);

            progDec.ProgramId = 13;
            Assert.IsTrue(ProgDecManager.Update(progDec) > 0);
        }
コード例 #3
0
        public ActionResult Insert()
        {
            HttpClient client = InitializeClient();

            ProgDec progDec = new ProgDec();

            return(View("Create", progDec));
        }
コード例 #4
0
ファイル: utProgDec.cs プロジェクト: Parker-Student/ProgDec
        public void InsertTest()
        {
            ProgDec progDec = new ProgDec {
                ProgramId = 12, StudentId = 4
            };

            Assert.AreNotEqual(0, ProgDecManager.Insert(progDec));
        }
コード例 #5
0
        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));
        }
コード例 #6
0
        public void InsertTest()
        {
            ProgDec progdec = new ProgDec();

            progdec.ChangeDate = DateTime.Now;
            progdec.StudentId  = -99;
            progdec.ProgramId  = 4;

            bool result = progdec.Insert();

            Assert.IsTrue(result);
        }
コード例 #7
0
 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));
     }
 }
コード例 #8
0
 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));
     }
 }
コード例 #9
0
 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));
     }
 }
コード例 #10
0
        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);
        }
コード例 #11
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));
        }
コード例 #12
0
 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;
     }
 }
コード例 #13
0
        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);
            }
        }
コード例 #14
0
        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);
        }
コード例 #15
0
 protected void ddlChangeDate_SelectedIndexChanged(object sender, EventArgs e)
 {
     progDec = progDecs[ddlChangeDate.SelectedIndex];
     ddlStudents.SelectedValue = progDec.StudentId.ToString();
     ddlPrograms.SelectedValue = progDec.ProgramId.ToString();
 }
コード例 #16
0
 public static int Update(ProgDec progDec)
 {
     return(Update(progDec.Id,
                   progDec.ProgramId,
                   progDec.StudentId));
 }