Beispiel #1
0
        public ActionResult AddNewInstructor(AddInstructorViewModel newInstructor)
        {
            if (ModelState.IsValid)
            {
                Instructor instructor = new Instructor
                {
                    InstructorIdentificator = ObjectId.GenerateNewId().ToString(),
                    FirstName         = newInstructor.FirstName,
                    LastName          = newInstructor.LastName,
                    Email             = newInstructor.Email,
                    Phone             = newInstructor.Phone,
                    Country           = newInstructor.Country,
                    City              = newInstructor.City,
                    PostCode          = newInstructor.PostCode,
                    Address           = newInstructor.Address,
                    NumberOfApartment = newInstructor.NumberOfApartment
                };

                _context.AddInstructor(instructor);

                return(RedirectToAction("AddNewInstructorConfirmation", new { instructorIdentificator = instructor.InstructorIdentificator }));
            }

            return(View(newInstructor));
        }
Beispiel #2
0
        public ActionResult DisplayAllInstructors()
        {
            var Instructors = _context.GetInstructors();
            List <AddInstructorViewModel> DisplayInstructors = new List <AddInstructorViewModel>();

            foreach (var instructor in Instructors)
            {
                AddInstructorViewModel singleInstructor = new AddInstructorViewModel
                {
                    FirstName         = instructor.FirstName,
                    LastName          = instructor.LastName,
                    Email             = instructor.Email,
                    Phone             = instructor.Phone,
                    Country           = instructor.Country,
                    City              = instructor.City,
                    PostCode          = instructor.PostCode,
                    Address           = instructor.Address,
                    NumberOfApartment = instructor.NumberOfApartment
                };

                DisplayInstructors.Add(singleInstructor);
            }

            return(View(DisplayInstructors));
        }
Beispiel #3
0
        public ActionResult AddNewInstructorConfirmation(string instructorIdentificator)
        {
            if (instructorIdentificator != null)
            {
                Instructor instructor = _context.GetInstructorById(instructorIdentificator);

                AddInstructorViewModel singleInstructor = new AddInstructorViewModel
                {
                    FirstName         = instructor.FirstName,
                    LastName          = instructor.LastName,
                    Email             = instructor.Email,
                    Phone             = instructor.Phone,
                    Country           = instructor.Country,
                    City              = instructor.City,
                    PostCode          = instructor.PostCode,
                    Address           = instructor.Address,
                    NumberOfApartment = instructor.NumberOfApartment
                };

                return(View(singleInstructor));
            }

            return(RedirectToAction(nameof(AddNewInstructor)));
        }