Exemple #1
0
        public IHttpActionResult Get(string id)
        {
            var item = context.Tbl_Accounts1.Where(p => p.UserID == id).FirstOrDefault();

            if (item == null)
            {
                return(StatusCode(HttpStatusCode.NoContent));
            }
            else
            {
                Tbl_Accounts1 cat = new Tbl_Accounts1();
                cat.AccountID = item.AccountID;
                cat.UserID    = item.UserID;
                cat.Password  = item.Password;
                cat.Type      = item.Type;
                cat.Status    = item.Status;
                cat.links.Add(new Links()
                {
                    HRef = "http://localhost:57254/api/Accounts", Method = "GET", Rel = "All Resources"
                });
                cat.links.Add(new Links()
                {
                    HRef = "http://localhost:57254/api/Accounts/" + cat.UserID, Method = "GET", Rel = "Self"
                });

                return(Ok(cat));
            }
        }
Exemple #2
0
        public IHttpActionResult Get()
        {
            var list = context.Tbl_Accounts1.ToList();
            List <Tbl_Accounts1> categories = new List <Tbl_Accounts1>();

            foreach (var item in list)
            {
                Tbl_Accounts1 cat = new Tbl_Accounts1();
                cat.AccountID = item.AccountID;
                cat.UserID    = item.UserID;
                cat.Password  = item.Password;
                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.UserID, Method = "GET", Rel = "Specific Resource"
                });


                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));
        }
        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"));
        }