Example #1
0
        public ActionResult SaveStudent([ModelBinder(typeof(MyStudentModelBinder))] StudentModel e, string BtnSubmit)
        {
            switch (BtnSubmit)
            {
            case "Save":
                if (ModelState.IsValid)
                {
                    StudentBusinessLayer stubal = new StudentBusinessLayer();
                    stubal.Savestudent(e);
                    //return Content(e.FirstName + "|" + e.LastName + "|" + e.Age);
                    return(RedirectToAction("Index"));
                }
                else
                {
                    //return View("CreateStudent");
                    CreateStudentViewModel csm = new CreateStudentViewModel();
                    csm.FirstName = e.FirstName;
                    csm.LastName  = e.LastName;
                    if (e.Age > 0)
                    {
                        csm.Age = e.Age;
                    }
                    else
                    {
                        csm.Age = 0;
                    }
                    return(View("CreateStudent", csm));
                }

            case "Cancel":
                return(RedirectToAction("Index"));
            }
            return(new EmptyResult());
        }
Example #2
0
        public ActionResult Edit(/*StudentsDetailsViewModel studentDetailsModel*/)
        {
            StudentsDetailsViewModel studentDetailsModel = new StudentsDetailsViewModel();

            UpdateModel <IStudentDetails>(studentDetailsModel);

            if (ModelState.IsValid)
            {
                StudentDetails studentDetails = new StudentDetails();

                studentDetails.Id        = studentDetailsModel.Id;
                studentDetails.FirstName = studentDetailsModel.FirstName;
                studentDetails.LastName  = studentDetailsModel.LastName;
                foreach (string strStudentEmail in studentDetailsModel.studentEmails)
                {
                    studentDetails.studentEmails.Add(strStudentEmail);
                }

                StudentBusinessLayer studentBusinessLayer = new StudentBusinessLayer();
                studentBusinessLayer.UpdateStudent(studentDetails);

                return(RedirectToAction("Index"));
            }
            return(View());
        }
        public ActionResult Record_Get()
        {
            ViewBag.Message = TempData["Message"];
            StudentBusinessLayer studentBuisnessLayer = new StudentBusinessLayer();
            List <Student>       students             = studentBuisnessLayer.Students.ToList();

            return(View(students));
        }
        public ActionResult TrackByStud_Get()
        {
            StudentBusinessLayer studentBuisnessLayer = new StudentBusinessLayer();
            List <Student>       students             = studentBuisnessLayer.Students.ToList();

            ViewBag.studentList = new SelectList(students, "StudentId", "StudentName");
            return(View());
        }
        public ActionResult Track_Post(string datepicker)
        {
            ViewBag.Message = "No records found for the selected date";
            DateTime             selDate = DateTime.ParseExact(datepicker, "MM/dd/yyyy", null);
            StudentBusinessLayer studentBuisnessLayer = new StudentBusinessLayer();
            List <Student>       students             = studentBuisnessLayer.StudentsAttendance(selDate).ToList();

            return(View(students));
        }
Example #6
0
        static void QueryBlog()
        {
            StudentBusinessLayer st = new StudentBusinessLayer();
            var classs = st.Query();

            foreach (var itme in classs)
            {
                Console.WriteLine(itme.Classid + "" + itme.ClassName);
            }
        }
        public ActionResult TrackByStud_Post(int studentList)
        {
            StudentBusinessLayer studentBuisnessLayer = new StudentBusinessLayer();
            List <Student>       students             = studentBuisnessLayer.Students.ToList();

            ViewBag.studentList = new SelectList(students, "StudentId", "StudentName");
            List <Attendnace> attendanceList = studentBuisnessLayer.GetAttendanceByStudent(studentList).ToList();

            return(View(attendanceList));
        }
Example #8
0
        static void Delete()
        {
            StudentBusinessLayer ss = new StudentBusinessLayer();

            Console.Write("请输入id");
            int   id   = int.Parse(Console.ReadLine());
            Class cals = ss.Query(id);

            ss.Delete(cals);
        }
Example #9
0
        static void createBlog()
        {
            Console.WriteLine("输入班级名称");
            string name   = Console.ReadLine();
            Class  classa = new Class();

            classa.ClassName = name;
            StudentBusinessLayer sss = new StudentBusinessLayer();

            sss.Add(classa);
        }
Example #10
0
        public ActionResult Delete(int StudentId)
        {
            StudentDetails studentDetails = new StudentDetails();

            studentDetails.Id = StudentId;

            StudentBusinessLayer studentBusinessLayer = new StudentBusinessLayer();

            studentBusinessLayer.DeleteStudent(studentDetails);

            return(RedirectToAction("Index"));
        }
        public ActionResult Record_Post(List <Student> students, string datepicker)
        {
            DateTime selDate = DateTime.ParseExact(datepicker, "MM/dd/yyyy", null);

            TryUpdateModel(students);
            if (ModelState.IsValid)
            {
                StudentBusinessLayer studentBuisnessLayer = new StudentBusinessLayer();
                string msg = studentBuisnessLayer.UpdateAttendance(students, selDate);
                TempData["Message"] = msg;
            }
            return(RedirectToAction("Record"));
        }
Example #12
0
        static void Update()
        {
            Console.WriteLine("请输入id");
            int id = int.Parse(Console.ReadLine());
            StudentBusinessLayer ss = new StudentBusinessLayer();
            Class clas = ss.Query(id);

            Console.WriteLine("请输入新名");
            string name = Console.ReadLine();

            clas.ClassName = name;
            ss.Update(clas);
        }
Example #13
0
        public ActionResult AddEmail(FormCollection formCollection)
        {
            StudentDetails           studentDetails      = new StudentDetails();
            StudentsDetailsViewModel studentDetailsModel = new StudentsDetailsViewModel();

            studentDetails.Id = Convert.ToInt32(formCollection["Id"]);
            studentDetails.studentEmails.Add(formCollection["Student Email"]);

            StudentBusinessLayer studentBusinessLayer = new StudentBusinessLayer();

            studentBusinessLayer.AddStudentEmail(studentDetails);

            return(RedirectToAction("Index"));
        }
Example #14
0
        public ActionResult Edit(int studentId)
        {
            StudentBusinessLayer     studentBusinessLayer = new StudentBusinessLayer();
            StudentsDetailsViewModel studentDetailsModel  = new StudentsDetailsViewModel();

            studentDetailsModel.Id        = studentBusinessLayer.studentListWithDetails.Where(stuDetails => stuDetails.Id == studentId).Single().Id;
            studentDetailsModel.FirstName = studentBusinessLayer.studentListWithDetails.Where(stuDetails => stuDetails.Id == studentId).Single().FirstName;
            studentDetailsModel.LastName  = studentBusinessLayer.studentListWithDetails.Where(stuDetails => stuDetails.Id == studentId).Single().LastName;
            foreach (string strStudentEmail in studentBusinessLayer.studentListWithDetails.Where(stuDetails => stuDetails.Id == studentId).Single().studentEmails)
            {
                studentDetailsModel.studentEmails.Add(strStudentEmail);
            }

            return(View(studentDetailsModel));
        }
Example #15
0
        [HttpPost] //只为 Post 请求开启
        public ActionResult DoLogin(UserDetailsModels u)
        {
            StudentBusinessLayer sbl = new StudentBusinessLayer();

            if (sbl.IsValidUser(u))
            {
                //创建一个认证的 Cookie
                FormsAuthentication.SetAuthCookie(u.UserName, false);
                return(RedirectToAction("Index", "Student"));
            }
            else
            {
                ModelState.AddModelError("CredentialError", "Invalid Username or Password");
                return(View("Login"));
            }
        }
Example #16
0
        public ActionResult Create(FormCollection formCollection)
        {
            if (ModelState.IsValid)
            {
                StudentDetails studentDetails = new StudentDetails();

                studentDetails.FirstName = formCollection["FirstName"];
                studentDetails.LastName  = formCollection["LastName"];
                studentDetails.studentEmails.Add(formCollection["Student Email"]);

                StudentBusinessLayer studentBusinessLayer = new StudentBusinessLayer();
                studentBusinessLayer.AddStudent(studentDetails);

                return(RedirectToAction("Index"));
            }
            return(View());
        }
Example #17
0
        /// <summary>
        /// Generate an EnrollViewModel instance with a Enroll instance
        /// </summary>
        /// <param name="enroll"></param>
        public EnrollViewModel(Enroll enroll)
        {
            Id         = enroll.Id;
            StuId      = enroll.StuId;
            CourseCode = enroll.CourseCode;
            Year       = enroll.Year.Value;
            Semester   = enroll.Semester.Value;

            //get the course name
            CourseBusinessLayer courseBL = new CourseBusinessLayer();

            CourseName = courseBL.FindCourseName(CourseCode);

            //get the student name
            StudentBusinessLayer stuBL = new StudentBusinessLayer();

            StuName = stuBL.FindStuName(StuId);
        }
Example #18
0
 protected override ValidationResult IsValid(object value, ValidationContext validationContext)
 {
     if (value == null) // Checking for Empty Value
     {
         return(new ValidationResult("Student ID is required"));
     }
     else
     {
         //Search in the databases to check if the value exists in the column of StuId
         StudentBusinessLayer stuBL = new StudentBusinessLayer();
         string stuId = (string)value;
         if (stuBL.StudentExistsByStuId(stuId))
         {
             return(new ValidationResult($"Student ID {stuId} already exists."));
         }
     }
     return(ValidationResult.Success);
 }
Example #19
0
        // GET: Student Index
        public ActionResult Index()
        {
            StudentBusinessLayer            studentBusinessLayer        = new StudentBusinessLayer();
            StudentIndexViewModel           studentIndexModel           = new StudentIndexViewModel();
            List <StudentsDetailsViewModel> studentDetailsViewModelList = new List <StudentsDetailsViewModel>();

            foreach (StudentDetails studentDetails in studentBusinessLayer.studentListWithDetails)
            {
                studentDetailsViewModelList.Add(new StudentsDetailsViewModel());
                studentDetailsViewModelList.Last().Id        = studentDetails.Id;
                studentDetailsViewModelList.Last().FirstName = studentDetails.FirstName;
                studentDetailsViewModelList.Last().LastName  = studentDetails.LastName;

                foreach (string strStudentEmail in studentDetails.studentEmails)
                {
                    studentDetailsViewModelList.Last().studentEmails.Add(strStudentEmail);
                }
            }
            studentIndexModel.viewStudentListWithDetails = studentDetailsViewModelList;
            return(View(studentIndexModel.viewStudentListWithDetails));
        }
Example #20
0
        public ActionResult Index()
        {
            StudentBusinessLayer sbl    = new StudentBusinessLayer();
            List <StudentModel>  smList = new List <StudentModel>();

            smList = sbl.GetStudents();
            List <StudentViewModel> svmlist = new List <StudentViewModel>();

            foreach (StudentModel item in smList)
            {
                StudentViewModel svm = new StudentViewModel();
                svm.StudentName = item.FirstName + " " + item.LastName;
                svm.Age         = item.Age;
                svm.AgeColor    = svm.Age > 18 ? "Red" : "darkseagreen";
                svmlist.Add(svm);
            }
            StudentListViewModel slvm = new StudentListViewModel();

            slvm.Student  = svmlist;
            slvm.UserName = User.Identity.Name;
            return(View("Index", slvm));
        }