Esempio n. 1
0
        public IHttpActionResult Get(string id)
        {
            var item = context.Tbl_PreStudent.Where(p => p.StudentID == id).FirstOrDefault();

            if (item == null)
            {
                return(StatusCode(HttpStatusCode.NoContent));
            }
            else
            {
                Tbl_PreStudent cat = new Tbl_PreStudent();
                cat.ConfrimID        = item.ConfrimID;
                cat.StudentID        = item.StudentID;
                cat.FirstName        = item.FirstName;
                cat.LastName         = item.LastName;
                cat.BirthDate        = item.BirthDate;
                cat.DepartmentID     = item.DepartmentID;
                cat.FatherName       = item.FatherName;
                cat.MotherName       = item.MotherName;
                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.AdmissionDate       = item.AdmissionDate;
                cat.GraduationDate      = item.GraduationDate;
                cat.PerSemesterRecordID = item.PerSemesterRecordID;
                cat.DocumentsGiven      = item.DocumentsGiven;
                cat.Password            = item.Password;
                cat.Picture             = item.Picture;
                cat.Type                = item.Type;

                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.StudentID, Method = "GET", Rel = "Specific Resource"
                });
                cat.links.Add(new Links()
                {
                    HRef = "http://localhost:57254/api/Posts/" + cat.StudentID, Method = "PUT", Rel = "Resource Edit"
                });
                cat.links.Add(new Links()
                {
                    HRef = "http://localhost:57254/api/Posts/" + cat.StudentID, Method = "DELETE", Rel = "Resource Delete"
                });
                cat.links.Add(new Links()
                {
                    HRef = "http://localhost:57254/api/Posts", Method = "POST", Rel = "Resource Create"
                });
                return(Ok(cat));
            }
        }
Esempio n. 2
0
        public IHttpActionResult Get()
        {
            var list = context.Tbl_PreStudent.ToList();
            List <Tbl_PreStudent> categories = new List <Tbl_PreStudent>();

            foreach (var item in list)
            {
                Tbl_PreStudent cat = new Tbl_PreStudent();
                cat.ConfrimID        = item.ConfrimID;
                cat.StudentID        = item.StudentID;
                cat.FirstName        = item.FirstName;
                cat.LastName         = item.LastName;
                cat.BirthDate        = item.BirthDate;
                cat.DepartmentID     = item.DepartmentID;
                cat.FatherName       = item.FatherName;
                cat.MotherName       = item.MotherName;
                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.AdmissionDate       = item.AdmissionDate;
                cat.GraduationDate      = item.GraduationDate;
                cat.PerSemesterRecordID = item.PerSemesterRecordID;
                cat.DocumentsGiven      = item.DocumentsGiven;
                cat.Password            = item.Password;
                cat.Picture             = item.Picture;
                cat.Type                = item.Type;

                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.StudentID, Method = "GET", Rel = "Specific Resource"
                });
                cat.links.Add(new Links()
                {
                    HRef = "http://localhost:57254/api/Posts/" + cat.StudentID, Method = "PUT", Rel = "Resource Edit"
                });
                cat.links.Add(new Links()
                {
                    HRef = "http://localhost:57254/api/Posts/" + cat.StudentID, 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_PreStudent pre)
        {
            var item = context.Tbl_PreStudent.Where(x => x.StudentID == pre.StudentID).FirstOrDefault();

            Tbl_Student cat = new Tbl_Student();

            cat.StudentID        = item.StudentID;
            cat.FirstName        = item.FirstName;
            cat.LastName         = item.LastName;
            cat.BirthDate        = item.BirthDate;
            cat.DepartmentID     = item.DepartmentID;
            cat.FatherName       = item.FatherName;
            cat.MotherName       = item.MotherName;
            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.AdmissionDate       = item.AdmissionDate;
            cat.GraduationDate      = item.GraduationDate;
            cat.PerSemesterRecordID = item.PerSemesterRecordID;
            cat.DocumentsGiven      = item.DocumentsGiven;
            cat.Password            = item.Password;
            cat.Picture             = item.Picture;
            cat.Type                = item.Type;
            Tbl_Accounts1 ac = new Tbl_Accounts1();

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

            context.Tbl_Student.Add(cat);
            context.Tbl_Accounts1.Add(ac);
            context.Tbl_PreStudent.Remove(item);
            context.SaveChanges();
            return(Created(Url.Link("GetStudentById", new { id = cat.StudentID }), cat));
        }
        public ActionResult StudentRegister(Tbl_PreStudent 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("~/StudentImage/"), pic);
                file.SaveAs(path);
            }
            tbl.Picture = pic;


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

            /* tbl1.Email = tbl1.Email;
             * tbl1.Password = tbl.Password;
             * tbl1.Type = tbl.Type;
             * tbl1.UserID = tbl.StudentID;
             * _unitOfWork.GetRepositoryInstance<Tbl_Accounts>().Add(tbl1);*/
            return(RedirectToAction("Index"));
        }
        public ActionResult ConfirmStudent(int id, Tbl_Student tbl, Tbl_PreStudent tbl1, Tbl_Accounts1 tbl2)
        {
            Tbl_PreStudent k = _unitOfWork.GetRepositoryInstance <Tbl_PreStudent>().GetAllRecordsIQueryable().Where(x => x.ConfrimID == id).FirstOrDefault();

            tbl.StudentID        = k.StudentID;
            tbl.FatherName       = k.FatherName;
            tbl.FirstName        = k.FirstName;
            tbl.LastName         = k.LastName;
            tbl.MotherName       = k.MotherName;
            tbl.GraduationDate   = k.GraduationDate;
            tbl.MaritalStatus    = k.MaritalStatus;
            tbl.Nationality      = k.Nationality;
            tbl.Password         = k.Password;
            tbl.PresentAddress   = k.PresentAddress;
            tbl.PermanentAddress = k.PermanentAddress;
            tbl.Phone            = k.Phone;
            tbl.Picture          = k.Picture;
            tbl.Religion         = k.Religion;
            tbl.Sex                 = k.Sex;
            tbl.Email               = k.Email;
            tbl.DocumentsGiven      = k.DocumentsGiven;
            tbl.DepartmentID        = k.DepartmentID;
            tbl.BloodGroup          = k.BloodGroup;
            tbl.BirthDate           = k.BirthDate;
            tbl.Type                = k.Type;
            tbl.AdmissionDate       = k.AdmissionDate;
            tbl.PerSemesterRecordID = k.PerSemesterRecordID;
            _unitOfWork.GetRepositoryInstance <Tbl_Student>().Add(tbl);
            _unitOfWork.GetRepositoryInstance <Tbl_PreStudent>().Remove(k);
            tbl2.Status   = "Active";
            tbl2.Password = tbl.Password;
            tbl2.Type     = tbl.Type;
            tbl2.UserID   = tbl.StudentID;
            _unitOfWork.GetRepositoryInstance <Tbl_Accounts1>().Add(tbl2);


            return(RedirectToAction("StudentRegistrationConfirm"));
        }
Esempio n. 6
0
        public IHttpActionResult Put([FromUri] string id, [FromBody] Tbl_PreStudent item)
        {
            var cat = context.Tbl_PreStudent.Where(p => p.StudentID == id).FirstOrDefault();

            if (cat == null)
            {
                return(StatusCode(HttpStatusCode.NoContent));
            }
            else
            {
                cat.ConfrimID        = item.ConfrimID;
                cat.StudentID        = item.StudentID;
                cat.FirstName        = item.FirstName;
                cat.LastName         = item.LastName;
                cat.BirthDate        = item.BirthDate;
                cat.DepartmentID     = item.DepartmentID;
                cat.FatherName       = item.FatherName;
                cat.MotherName       = item.MotherName;
                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.AdmissionDate       = item.AdmissionDate;
                cat.GraduationDate      = item.GraduationDate;
                cat.PerSemesterRecordID = item.PerSemesterRecordID;
                cat.DocumentsGiven      = item.DocumentsGiven;
                cat.Password            = item.Password;
                cat.Picture             = item.Picture;
                cat.Type                = item.Type;
                return(Ok(item));
            }
        }
        public ActionResult StudentDetails(int id)
        {
            Tbl_PreStudent k = _unitOfWork.GetRepositoryInstance <Tbl_PreStudent>().GetAllRecordsIQueryable().Where(x => x.ConfrimID == id).FirstOrDefault();

            return(View(k));
        }
Esempio n. 8
0
 public IHttpActionResult Post([FromBody] Tbl_PreStudent preStudent)
 {
     context.Tbl_PreStudent.Add(preStudent);
     context.SaveChanges();
     return(Created(Url.Link("GetPreStudentById", new { id = preStudent.StudentID }), preStudent));
 }