Beispiel #1
0
        public async Task <IActionResult> PutMyCourses(int id, MyCourses myCourses)
        {
            if (id != myCourses.itemID)
            {
                return(BadRequest());
            }

            _context.Entry(myCourses).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!MyCoursesExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
Beispiel #2
0
        public async Task <ActionResult <MyCourses> > PostMyCourses(MyCourses myCourses)
        {
            _context.Database.EnsureCreated();
            _context.myCourses.Add(myCourses);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetMyCourses", new { id = myCourses.itemID }, myCourses));
        }
Beispiel #3
0
        private void MyCourses_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (MyCourses.SelectedItem == null)
            {
                return;
            }
            RemoveStudentCourses cd = new RemoveStudentCourses(MyCourses.GetItemText(MyCourses.SelectedItem).ToString(), IDText.Text.ToString());

            cd.ShowDialog();
        }
Beispiel #4
0
        private void btn_download_Click(object sender, EventArgs e)
        {
            SaveFileDialog savefile = new SaveFileDialog();

            savefile.DefaultExt = "*.docx";
            savefile.Filter     = "DOCX files(*.docx)|*.docx";
            savefile.FileName   = "khoa-hoc";

            if (savefile.ShowDialog() == DialogResult.OK && savefile.FileName.Length > 0)
            {
                MyCourses.DownloadWord(dgv_list, savefile.FileName, "DANH SÁCH KHÓA HỌC");
                MessageBox.Show("File saved!", "Message Dialog", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
Beispiel #5
0
        private void MyCourses_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (MyCourses.SelectedItem == null)
            {
                return;
            }
            // use a SqlAdapter to execute the query
            string Item = MyCourses.GetItemText(MyCourses.SelectedItem);

            if (Item == "NO Registered Courses")
            {
                return;
            }
            CourseDetails ShowCourseDetails = new CourseDetails(Item);

            ShowCourseDetails.ShowDialog();
        }
        public ActionResult FindCourse(MyCourses cour)
        {
            string        coursename = Request.Form["CourseNameTB"].ToString();
            int           id         = (int)Session["ID"];
            SqlConnection con        = new SqlConnection();

            con.ConnectionString = "Data Source=DESKTOP-23GVLKN;database=WPF;Integrated Security=SSPI";
            SqlCommand sqlcomm = new SqlCommand(@"select DISTINCT coursename,day,startHour,endHour,class,moedAYear,moedAMonth,moedADay,classA,moedBYear,moedBMonth,moedBDay,classB from cou_lec_stu where LecturerId= '" + id + "' and coursename= '" + coursename + "'", con);;

            sqlcomm.Connection = con;
            con.Open();
            SqlDataReader sdr = sqlcomm.ExecuteReader();

            List <MyCourses> objmodel = new List <MyCourses>();

            if (sdr.HasRows)
            {
                while (sdr.Read())
                {
                    var details = new MyCourses();
                    details.coursename = sdr["coursename"].ToString();
                    details.day        = sdr["day"].ToString();
                    details.startHour  = TimeSpan.Parse(sdr["startHour"].ToString());
                    details.endHour    = TimeSpan.Parse(sdr["endHour"].ToString());
                    details.Class      = sdr["Class"].ToString();
                    details.moedADay   = Convert.ToInt32(sdr["moedADay"]);
                    details.moedAMonth = Convert.ToInt32(sdr["moedAMonth"]);
                    details.moedAYear  = Convert.ToInt32(sdr["moedAYear"]);
                    details.classA     = sdr["classA"].ToString();
                    details.moedBDay   = Convert.ToInt32(sdr["moedBDay"]);
                    details.moedBMonth = Convert.ToInt32(sdr["moedBMonth"]);
                    details.moedBYear  = Convert.ToInt32(sdr["moedBYear"]);
                    details.classB     = sdr["classB"].ToString();
                    objmodel.Add(details);
                }
                cour.info = objmodel;
                con.Close();
            }

            return(View("LecturerMyCourses", cour));
        }
Beispiel #7
0
        public async Task <bool> EnrollForCourse(string Email, int CourseID)
        {
            MyCourses objMyCoursesRequest;

            try
            {
                using (var client = new HttpClient())
                {
                    objMyCoursesRequest = new MyCourses()
                    {
                        CourseId = CourseID.ToString(), emailID = Email, enrollmentDate = DateTime.Today.ToString("D")
                    };
                    var SerilzeRequestObject = JsonConvert.SerializeObject(objMyCoursesRequest);
                    //  client.BaseAddress = new Uri(Convert.ToString(configuration.GetSection("URLpatterns:addCourse").Value));
                    var httpRequest = new HttpRequestMessage(HttpMethod.Post, (Convert.ToString(configuration.GetSection("URLpatterns:addCourse").Value)));
                    httpRequest.Content = new StringContent(SerilzeRequestObject, Encoding.UTF8, "application/json");;
                    var Response = await client.SendAsync(httpRequest);

                    if (Response.IsSuccessStatusCode)
                    {
                        var ReadResponse = await Response.Content.ReadAsStringAsync();

                        // var DserlizedResponse = JsonConvert.DeserializeObject<List<MyCourses>>(ReadResponse);
                        return(true);
                    }
                    else
                    {
                        Response.EnsureSuccessStatusCode(); return(false);
                    }
                }
            }
            catch
            {
                return(false);
            }
            throw new NotImplementedException();
        }