Exemple #1
0
        public ToDoClass GetToDo(int ToDoID)
        {
            HttpWebRequest  request  = (HttpWebRequest)WebRequest.Create("http://aegisservice20190412102455.azurewebsites.net/AegisService.svc/GetToDo/" + ToDoID);
            HttpWebResponse response = request.GetResponse() as HttpWebResponse;
            Stream          stream   = response.GetResponseStream();
            StreamReader    reader   = new StreamReader(stream);
            string          str      = reader.ReadToEnd();
            GetToDoResult   todo     = JsonConvert.DeserializeObject <GetToDoResult>(str);
            ToDoClass       t        = todo.todo;

            return(t);
        }
Exemple #2
0
 public void btnSubmitEdit_click(object s, EventArgs e)
 {
     if (ValidateForm(pnlEdit))
     {
         //Insert new record
         ToDoClass todo = new ToDoClass();
         todo.ToDoID      = Convert.ToInt32(lblSelectedID.Text);
         todo.Title       = txtTitleEdit.Text;
         todo.Description = txtDescriptionEdit.Text;
         todo.StartDate   = Convert.ToDateTime(txtStartEdit.Text);
         todo.EndDate     = Convert.ToDateTime(txtEndEdit.Text);
         todo.UpdatedBy   = 1; //use session id from cookie
         todo.Completed   = Convert.ToBoolean(rblCompletedEdit.SelectedValue);
         string obj = JsonConvert.SerializeObject(todo);
         //aegisservice20190412102455.azurewebsites.net
         HttpWebRequest req = (HttpWebRequest)WebRequest.Create("http://aegisservice20190412102455.azurewebsites.net/AegisService.svc/PutToDo");
         req.Method        = "PUT";
         req.ContentType   = "application/json";
         req.ContentLength = obj.Length;
         using (var streamWriter = new StreamWriter(req.GetRequestStream()))
         {
             streamWriter.Write(obj);
         }
         HttpWebResponse response = (HttpWebResponse)req.GetResponse();
         using (var streamReader = new StreamReader(response.GetResponseStream(), Encoding.UTF8))
         {
             string result = streamReader.ReadToEnd();
             int    res    = Convert.ToInt32(result);
             if (response.StatusCode == HttpStatusCode.OK)
             {
                 ClearForm(pnlEdit);
                 FillGrid(Convert.ToInt32(lblUserID.Text));
                 pnlGrid.Visible = true;
                 pnlEdit.Visible = false;
             }
             else
             {
                 lblMsg.Text    = "ToDo not inserted";
                 lblMsg.Visible = true;
             }
         }
     }
 }
Exemple #3
0
 public void btnSubmitComplete_click(object s, EventArgs e)
 {
     if (ValidateForm(pnlComplete))
     {
         ToDoClass todo = new ToDoClass();
         todo.ToDoID    = Convert.ToInt32(lblSelectedID.Text);
         todo.Completed = Convert.ToBoolean(rblCompleteConfirm.SelectedValue);
         todo.UpdatedBy = Convert.ToInt32(lblUserID.Text);
         string obj = JsonConvert.SerializeObject(todo);
         //aegisservice20190412102455.azurewebsites.net
         HttpWebRequest req = (HttpWebRequest)WebRequest.Create("http://aegisservice20190412102455.azurewebsites.net/AegisService.svc/CompleteToDo");
         req.Method        = "PUT";
         req.ContentType   = "application/json";
         req.ContentLength = obj.Length;
         using (var streamWriter = new StreamWriter(req.GetRequestStream()))
         {
             streamWriter.Write(obj);
         }
         HttpWebResponse response = (HttpWebResponse)req.GetResponse();
         using (var streamReader = new StreamReader(response.GetResponseStream(), Encoding.UTF8))
         {
             string result = streamReader.ReadToEnd();
             int    res    = Convert.ToInt32(result);
             if (response.StatusCode == HttpStatusCode.OK)
             {
                 ClearForm(pnlComplete);
                 FillGrid(Convert.ToInt32(lblUserID.Text));
                 pnlGrid.Visible     = true;
                 pnlComplete.Visible = false;
             }
             else
             {
                 lblMsg.Text    = "ToDo not update";
                 lblMsg.Visible = true;
             }
         }
     }
 }
Exemple #4
0
 public void lnkGrid_click(object s, CommandEventArgs e)
 {
     pnlGrid.Visible    = false;
     lblSelectedID.Text = e.CommandArgument.ToString();
     //Load data for selected item
     if (lblSelection.Text == "Edit")
     {
         pnlEdit.Visible = true;
         ToDoClass todo = GetToDo(Convert.ToInt32(lblSelectedID.Text));
         txtDescriptionEdit.Text        = todo.Description;
         txtTitleEdit.Text              = todo.Title;
         txtStartEdit.Text              = todo.StartDate.ToString("yyyy-MM-dd");
         txtEndEdit.Text                = todo.EndDate.ToString("yyyy-MM-dd");
         rblCompletedEdit.SelectedValue = todo.Completed.ToString();
         lblDisableEdit.Text            = todo.Disabled.ToString();
     }
     else if (lblSelection.Text == "Complete")
     {
         pnlComplete.Visible = true;
         ToDoClass todo = GetToDo(Convert.ToInt32(lblSelectedID.Text));
         lblTitleComplete.Text       = todo.Title;
         lblDescriptionComplete.Text = todo.Description;
         lblStartDateComplete.Text   = todo.StartDate.ToString();
         lblEndDateComplete.Text     = todo.EndDate.ToString();
         //rblCompleteConfirm.SelectedValue = todo.Completed.ToString();
     }
     else if (lblSelection.Text == "Disable")
     {
         pnlDisable.Visible = true;
         ToDoClass todo = GetToDo(Convert.ToInt32(lblSelectedID.Text));
         lblTitleDisable.Text       = todo.Title;
         lblDescriptionDisable.Text = todo.Description;
         lblStartDateDisable.Text   = todo.StartDate.ToString();
         lblEndDateDisable.Text     = todo.EndDate.ToString();
         //rblConfirmDisable.SelectedValue = todo.Completed.ToString();
     }
 }