public static Resource[] fetchResourcesbyCourse(int _courseid)
        {
            dbManager db = new dbManager();
                Resource[] rsc = null;

                string sqlCommand;
                MySqlParameter[] param = new MySqlParameter[1];

                param[0] = new MySqlParameter("@courseid", _courseid);

                sqlCommand = "select * from Resource where courseid=@courseid";

                DataTable ds = db.fetchRows(sqlCommand, param);
                rsc = new Resource[ds.Rows.Count];
                int i = 0;

                foreach (DataRow dr in ds.Rows)
                {
                    rsc[i] = new Resource((int)dr["resourceid"],
                                        (ResourceType)Enum.Parse(typeof(ResourceType),dr["resourcetype"].ToString()),
                                        dr["resourcename"].ToString(),
                                        (int)dr["uploadedby"],
                                        (DateTime)dr["uploadedat"],
                                        (int)dr["Courseid"],
                                        dr["filename"].ToString());
                    i++;
                }

                return rsc;
        }
        protected void btnUpload_Click(object sender, EventArgs e)
        {
            int courseid = Convert.ToInt32(drpCourse.SelectedValue.ToString());
            DateTime UploadedAt = DateTime.UtcNow;
            if (fileResource.HasFile)
            {
                Resource rc = new Resource((ResourceType)Enum.Parse(typeof(ResourceType), drpResourceType.SelectedValue),
                                            txtResourceName.Text,
                                            (int)Session["UserId"],
                                            UploadedAt,
                                            courseid,
                                            fileResource.FileName);
                int sqlret = rc.addResource();

                rc.resourceId = Resource.fetchUploadedResource((int)Session["UserId"]);

                fileResource.SaveAs(HttpContext.Current.Request.PhysicalApplicationPath +
                    "\\input\\Resource_" + rc.resourceId.ToString() +
                                    System.IO.Path.GetExtension(fileResource.FileName));

                ContentType = System.Web.MimeMapping.GetMimeMapping(fileResource.FileName);

                AWSClass.UploadToS3("course-" + courseid.ToString(),
                             "Resource_" + rc.resourceId.ToString() + System.IO.Path.GetExtension(fileResource.FileName),
                             HttpContext.Current.Request.PhysicalApplicationPath + "\\input\\Resource_" + rc.resourceId.ToString() + System.IO.Path.GetExtension(fileResource.FileName),
                             ContentType,
                             System.IO.Path.GetFileName(fileResource.FileName));

                Course course = Course.fetchCoursebyId(courseid);
                if (rc.resourceType == ResourceType.Lectures || rc.resourceType == ResourceType.References)
                {
                    string topicarn = Course.fetchTopicARN(courseid);
                    AWSClass.publishToTopic(topicarn, "New File Uploaded on Classroom",
                        "Hi! A new document '" + txtResourceName.Text + "' has been uploaded for the course " + course.courseName + ". Please visit the MyCloudClassroom to download the document.Thanks!");
                }
                lblSuccess.Text = "File uploaded successfully.";
                lblSuccess.Visible = true;
                base.Context.Response.Redirect("MyFiles.aspx", false);
            }
            else
            {
                lblSuccess.Text = "No file found.";
                lblSuccess.Visible = true;
            }
        }