public IHttpActionResult PostNote([FromBody] Tbl_Notes pro, [FromUri] string id)
 {
     pro.TeacherID = id;
     context.Tbl_Notes.Add(pro);
     context.SaveChanges();
     return(Created(Url.Link("GetNotesByTeacherID", new { id = pro.TeacherID, id1 = pro.NotesID }), pro));
 }
        public ActionResult NotesUpload(Tbl_Notes tbl, HttpPostedFileBase file)
        {
            string pic = null;

            if (file != null)
            {
                pic = System.IO.Path.GetFileName(file.FileName);
                string path = System.IO.Path.Combine(Server.MapPath("~/Notes/"), pic);
                file.SaveAs(path);
            }
            tbl.Note = pic;
            string a = Session["userID"].ToString();

            tbl.TeacherID = a;

            _unitOfWork.GetRepositoryInstance <Tbl_Notes>().Add(tbl);
            return(RedirectToAction("MarksFinal"));
        }
        public IHttpActionResult GetNotesByTeacher([FromUri] string id)
        {
            var list = context.Tbl_Notes.Where(p => p.TeacherID == id);

            if (list.FirstOrDefault() == null)
            {
                return(StatusCode(HttpStatusCode.NoContent));
            }
            else
            {
                List <Tbl_Notes> comments = new List <Tbl_Notes>();
                foreach (var item in list)
                {
                    Tbl_Notes pro = new Tbl_Notes();
                    pro.NotesID   = item.NotesID;
                    pro.TeacherID = item.TeacherID;
                    pro.Note      = item.Note;
                    pro.SubjectID = item.SubjectID;
                    pro.SectionID = item.SectionID;
                    pro.links.Add(new Links()
                    {
                        HRef = "http://localhost:57254/api/Posts/" + id + "/Comments", Method = "GET", Rel = "Self"
                    });
                    pro.links.Add(new Links()
                    {
                        HRef = "http://localhost:57254/api/Posts/" + id + "/Comments/" + pro.NotesID, Method = "GET", Rel = "Specific Resource"
                    });
                    pro.links.Add(new Links()
                    {
                        HRef = "http://localhost:57254/api/Posts/" + id + "/Comments/" + pro.NotesID, Method = "PUT", Rel = "Resource Edit"
                    });
                    pro.links.Add(new Links()
                    {
                        HRef = "http://localhost:57254/api/Posts/" + id + "/Comments/" + pro.NotesID, Method = "DELETE", Rel = "Resource Delete"
                    });
                    pro.links.Add(new Links()
                    {
                        HRef = "http://localhost:57254/api/Posts/" + id + "/Comments", Method = "POST", Rel = "Resource Create"
                    });
                    comments.Add(pro);
                }
                return(Ok(comments));
            }
        }
        public IHttpActionResult GetNotesByTeacherID([FromUri] string id, int id1)
        {
            var list = context.Tbl_Notes.Where(p => p.TeacherID == id && p.NotesID == id1);

            if (list.FirstOrDefault() == null)
            {
                return(StatusCode(HttpStatusCode.NoContent));
            }
            else
            {
                List <Tbl_Notes> comments = new List <Tbl_Notes>();
                foreach (var item in list)
                {
                    Tbl_Notes pro = new Tbl_Notes();
                    pro.NotesID   = item.NotesID;
                    pro.TeacherID = item.TeacherID;
                    pro.Note      = item.Note;
                    pro.SubjectID = item.SubjectID;
                    pro.SectionID = item.SectionID;
                    comments.Add(pro);
                }
                return(Ok(comments));
            }
        }