Example #1
0
        public ActionResult Show(StudentAddVM StudentAddVM)
        {
            var students = _studentManager.GetAll();

            if (StudentAddVM.Name != null)
            {
                //students = students.Where(c => c.Name.Contains(student.Name)).ToList();
                students = students.Where(c => c.Name.ToLower().Contains(StudentAddVM.Name.ToLower())).ToList();
            }
            if (StudentAddVM.Address != null)
            {
                //students = students.Where(c => c.Address.Contains(student.Address)).ToList();
                students = students.Where(c => c.Address.ToLower().Contains(StudentAddVM.Address.ToLower())).ToList();
            }
            if (StudentAddVM.Contact != null)
            {
                //students = students.Where(c => c.Contact.Contains(student.Contact)).ToList();
                students = students.Where(c => c.Contact.ToLower().Contains(StudentAddVM.Contact.ToLower())).ToList();
            }
            if (StudentAddVM.Age > 0)
            {
                students = students.Where(c => c.Age == StudentAddVM.Age).ToList();
            }

            StudentAddVM.Students     = students;
            StudentAddVM.DistrictList = _districtManager.GetAll()
                                        .Select(c => new SelectListItem()
            {
                Value = c.ID.ToString(),
                Text  = c.Name
            });
            return(View(StudentAddVM));
        }
Example #2
0
        public ActionResult Delete(StudentAddVM StudentAddVM)
        {
            //string msg = "Failed";

            if (ModelState.IsValid)
            {
                var student = Mapper.Map <Student>(StudentAddVM);

                if (_studentManager.Delete(student))
                {
                    ViewBag.SuccessMsg = "Deleted!";
                }
                else
                {
                    ViewBag.ErrorMsg = "Failed!";
                }
            }
            else
            {
                ViewBag.ErrorMsg = "Validation!";
            }

            StudentAddVM.DistrictList = _districtManager.GetAll()
                                        .Select(c => new SelectListItem()
            {
                Value = c.ID.ToString(),
                Text  = c.Name
            });
            return(View(StudentAddVM));
        }
Example #3
0
        public ActionResult Add()
        {
            var viewModel = new StudentAddVM();

            viewModel.SetCourseItems(CourseRepository.GetAll());
            viewModel.SetMajorItems(MajorRepository.GetAll());
            return(View(viewModel));
        }
Example #4
0
        public ActionResult Add()
        {
            var model = new StudentAddVM();

            model.Courses = courseService.GetAll().Select(x => new SelectListItem()
            {
                Text  = x.Code,
                Value = x.Id.ToString()
            });
            return(View(model));
        }
Example #5
0
        public ActionResult Add()
        {
            StudentAddVM StudentAddVM = new StudentAddVM();

            StudentAddVM.DistrictList = _districtManager.GetAll()
                                        .Select(c => new SelectListItem()
            {
                Value = c.ID.ToString(),
                Text  = c.Name
            });

            return(View(StudentAddVM));
        }
Example #6
0
        public ActionResult Add([FromBody] StudentAddVM x)
        {
            var newStudent = new Student
            {
                ime                 = x.ime.RemoveTags(),
                prezime             = x.prezime.RemoveTags(),
                broj_indeksa        = x.broj_indeksa,
                datum_rodjenja      = x.datum_rodjenja,
                opstina_rodjenja_id = x.opstina_rodjenja_id,
                slika_studenta      = Config.SlikeURL + "empty.png",
                created_time        = DateTime.Now
            };

            _dbContext.Add(newStudent);
            _dbContext.SaveChanges();
            return(Get(newStudent.id));
        }
Example #7
0
        public ActionResult Edit(int Id)
        {
            Student student = new Student();

            student.ID = Id;
            student    = _studentManager.GetByID(student);

            StudentAddVM StudentAddVM = new StudentAddVM();

            StudentAddVM = Mapper.Map <StudentAddVM>(student);

            StudentAddVM.DistrictList = _districtManager.GetAll()
                                        .Select(c => new SelectListItem()
            {
                Value = c.ID.ToString(),
                Text  = c.Name
            });
            return(View(StudentAddVM));
        }
Example #8
0
        public ActionResult Add(StudentAddVM viewModel)
        {
            viewModel.Student.Courses = new List <Course>();

            foreach (var id in viewModel.SelectedCourseIds)
            {
                viewModel.Student.Courses.Add(CourseRepository.Get(id));
            }

            viewModel.Student.Major = MajorRepository.Get(viewModel.Student.Major.MajorId);

            if (!ModelState.IsValid)
            {
                viewModel.SetMajorItems(MajorRepository.GetAll());
                viewModel.SetCourseItems(CourseRepository.GetAll());
                return(View(viewModel));
            }

            StudentRepository.Add(viewModel.Student);

            return(RedirectToAction("List"));
        }
Example #9
0
        public ActionResult Add(StudentAddVM studentVM)
        {
            if (!ModelState.IsValid)
            {
                studentVM = new StudentAddVM();
                studentVM.SetCourseItems(CourseRepository.GetAll());
                studentVM.SetMajorItems(MajorRepository.GetAll());
                return(View(studentVM));
            }

            studentVM.Student.Courses = new List <Course>();


            foreach (var id in studentVM.SelectedCourseIds)
            {
                studentVM.Student.Courses.Add(CourseRepository.Get(id));
            }

            studentVM.Student.Major = MajorRepository.Get(studentVM.Student.Major.MajorId);

            StudentRepository.Add(studentVM.Student);

            return(RedirectToAction("List"));
        }