Example #1
0
        public IHttpActionResult Get(string id)
        {
            var item = context.Tbl_PreTeacher.Where(p => p.TeacherID == id).FirstOrDefault();

            if (item == null)
            {
                return(StatusCode(HttpStatusCode.NoContent));
            }
            else
            {
                Tbl_PreTeacher cat = new Tbl_PreTeacher();
                cat.ID           = item.ID;
                cat.TeacherID    = item.TeacherID;
                cat.FirstName    = item.FirstName;
                cat.LastName     = item.LastName;
                cat.BirthDate    = item.BirthDate;
                cat.DepartmentID = item.DepartmentID;

                cat.PresentAddress   = item.PresentAddress;
                cat.PermanentAddress = item.PermanentAddress;
                cat.Phone            = item.Phone;
                cat.Email            = item.Email;
                cat.Sex           = item.Sex;
                cat.Nationality   = item.Nationality;
                cat.Religion      = item.Religion;
                cat.MaritalStatus = item.MaritalStatus;
                cat.BloodGroup    = item.BloodGroup;

                cat.JoiningDate      = item.JoiningDate;
                cat.SalaryCategoryID = item.SalaryCategoryID;
                cat.DocumentsGiven   = item.DocumentsGiven;
                cat.Password         = item.Password;
                cat.Picture          = item.Picture;
                cat.Type             = item.Type;
                cat.Status           = item.Status;

                cat.links.Add(new Links()
                {
                    HRef = "http://localhost:57254/api/Posts", Method = "GET", Rel = "Self"
                });
                cat.links.Add(new Links()
                {
                    HRef = "http://localhost:57254/api/Posts/" + cat.TeacherID, Method = "GET", Rel = "Specific Resource"
                });
                cat.links.Add(new Links()
                {
                    HRef = "http://localhost:57254/api/Posts/" + cat.TeacherID, Method = "PUT", Rel = "Resource Edit"
                });
                cat.links.Add(new Links()
                {
                    HRef = "http://localhost:57254/api/Posts/" + cat.TeacherID, Method = "DELETE", Rel = "Resource Delete"
                });
                cat.links.Add(new Links()
                {
                    HRef = "http://localhost:57254/api/Posts", Method = "POST", Rel = "Resource Create"
                });
                return(Ok(cat));
            }
        }
Example #2
0
        public IHttpActionResult Get()
        {
            var list = context.Tbl_PreTeacher.ToList();
            List <Tbl_PreTeacher> categories = new List <Tbl_PreTeacher>();

            foreach (var item in list)
            {
                Tbl_PreTeacher cat = new Tbl_PreTeacher();
                cat.ID           = item.ID;
                cat.TeacherID    = item.TeacherID;
                cat.FirstName    = item.FirstName;
                cat.LastName     = item.LastName;
                cat.BirthDate    = item.BirthDate;
                cat.DepartmentID = item.DepartmentID;

                cat.PresentAddress   = item.PresentAddress;
                cat.PermanentAddress = item.PermanentAddress;
                cat.Phone            = item.Phone;
                cat.Email            = item.Email;
                cat.Sex           = item.Sex;
                cat.Nationality   = item.Nationality;
                cat.Religion      = item.Religion;
                cat.MaritalStatus = item.MaritalStatus;
                cat.BloodGroup    = item.BloodGroup;

                cat.JoiningDate      = item.JoiningDate;
                cat.SalaryCategoryID = item.SalaryCategoryID;
                cat.DocumentsGiven   = item.DocumentsGiven;
                cat.Password         = item.Password;
                cat.Picture          = item.Picture;
                cat.Type             = item.Type;
                cat.Status           = item.Status;

                cat.links.Add(new Links()
                {
                    HRef = "http://localhost:57254/api/Posts", Method = "GET", Rel = "Self"
                });
                cat.links.Add(new Links()
                {
                    HRef = "http://localhost:57254/api/Posts/" + cat.TeacherID, Method = "GET", Rel = "Specific Resource"
                });
                cat.links.Add(new Links()
                {
                    HRef = "http://localhost:57254/api/Posts/" + cat.TeacherID, Method = "PUT", Rel = "Resource Edit"
                });
                cat.links.Add(new Links()
                {
                    HRef = "http://localhost:57254/api/Posts/" + cat.TeacherID, Method = "DELETE", Rel = "Resource Delete"
                });
                cat.links.Add(new Links()
                {
                    HRef = "http://localhost:57254/api/Posts", Method = "POST", Rel = "Resource Create"
                });

                categories.Add(cat);
            }
            return(Ok(categories));
        }
        public IHttpActionResult Post([FromBody] Tbl_PreTeacher pre)
        {
            var item = context.Tbl_PreTeacher.Where(x => x.TeacherID == pre.TeacherID).FirstOrDefault();

            Tbl_Teacher1 cat = new Tbl_Teacher1();

            cat.ID           = item.ID;
            cat.TeacherID    = item.TeacherID;
            cat.FirstName    = item.FirstName;
            cat.LastName     = item.LastName;
            cat.BirthDate    = item.BirthDate;
            cat.DepartmentID = item.DepartmentID;

            cat.PresentAddress   = item.PresentAddress;
            cat.PermanentAddress = item.PermanentAddress;
            cat.Phone            = item.Phone;
            cat.Email            = item.Email;
            cat.Sex           = item.Sex;
            cat.Nationality   = item.Nationality;
            cat.Religion      = item.Religion;
            cat.MaritalStatus = item.MaritalStatus;
            cat.BloodGroup    = item.BloodGroup;

            cat.JoiningDate      = item.JoiningDate;
            cat.SalaryCategoryID = item.SalaryCategoryID;
            cat.DocumentsGiven   = item.DocumentsGiven;
            cat.Password         = item.Password;
            cat.Picture          = item.Picture;
            cat.Type             = item.Type;
            cat.Status           = item.Status;
            Tbl_Accounts1 ac = new Tbl_Accounts1();

            ac.UserID   = pre.TeacherID;
            ac.Password = item.Password;
            ac.Type     = item.Type;

            context.Tbl_Teacher1.Add(cat);
            context.Tbl_Accounts1.Add(ac);
            context.Tbl_PreTeacher.Remove(item);
            context.SaveChanges();
            return(Created(Url.Link("GetTeacherById", new { id = cat.TeacherID }), cat));
        }
Example #4
0
        public IHttpActionResult Put([FromUri] string id, [FromBody] Tbl_PreTeacher item)
        {
            var cat = context.Tbl_PreTeacher.Where(p => p.TeacherID == id).FirstOrDefault();

            if (cat == null)
            {
                return(StatusCode(HttpStatusCode.NoContent));
            }
            else
            {
                cat.ID           = item.ID;
                cat.TeacherID    = item.TeacherID;
                cat.FirstName    = item.FirstName;
                cat.LastName     = item.LastName;
                cat.BirthDate    = item.BirthDate;
                cat.DepartmentID = item.DepartmentID;

                cat.PresentAddress   = item.PresentAddress;
                cat.PermanentAddress = item.PermanentAddress;
                cat.Phone            = item.Phone;
                cat.Email            = item.Email;
                cat.Sex           = item.Sex;
                cat.Nationality   = item.Nationality;
                cat.Religion      = item.Religion;
                cat.MaritalStatus = item.MaritalStatus;
                cat.BloodGroup    = item.BloodGroup;

                cat.JoiningDate      = item.JoiningDate;
                cat.SalaryCategoryID = item.SalaryCategoryID;
                cat.DocumentsGiven   = item.DocumentsGiven;
                cat.Password         = item.Password;
                cat.Picture          = item.Picture;
                cat.Type             = item.Type;
                cat.Status           = item.Status;
                return(Ok(item));
            }
        }
        public ActionResult TeacherRegister(Tbl_PreTeacher tbl, Tbl_Accounts1 tbl1, HttpPostedFileBase file)
        {
            string pic = null;

            if (file != null)
            {
                pic = System.IO.Path.GetFileName(file.FileName);
                string path = System.IO.Path.Combine(Server.MapPath("~/TeacherImage/"), pic);
                file.SaveAs(path);
            }
            tbl.Picture = pic;



            _unitOfWork.GetRepositoryInstance <Tbl_PreTeacher>().Add(tbl);

            /*
             * tbl1.UserID = tbl.TeacherID;
             * tbl1.Password = tbl.Password;
             * tbl1.Email = tbl1.Email;
             * tbl1.Type = tbl.Type;
             * _unitOfWork.GetRepositoryInstance<Tbl_Accounts>().Add(tbl1);*/
            return(RedirectToAction("Index"));
        }
Example #6
0
 public IHttpActionResult Post([FromBody] Tbl_PreTeacher preTeacher)
 {
     context.Tbl_PreTeacher.Add(preTeacher);
     context.SaveChanges();
     return(Created(Url.Link("GetPreTeacherById", new { id = preTeacher.TeacherID }), preTeacher));
 }