Exemple #1
0
        public async Task <IActionResult> Create(EnrollmentViewModel model)
        {
            if (ModelState.IsValid)
            {
                string     uniqueFileName = UploadedFile(model);
                Enrollment enrol          = new Enrollment
                {
                    CourseId         = model.CourseId,
                    StudentId        = model.StudentId,
                    Semester         = model.Semester,
                    Year             = model.Year,
                    Grade            = model.Grade,
                    ProjectUrl       = model.ProjectUrl,
                    ExamPoints       = model.ExamPoints,
                    SeminalPoints    = model.SeminalPoints,
                    ProjectPoints    = model.ProjectPoints,
                    AdditionalPoints = model.AdditionalPoints,
                    FinishDate       = model.FinishDate,
                    FileName         = uniqueFileName,
                };
                _context.Add(enrol);
                await _context.SaveChangesAsync();

                ViewData["Courseid"]  = new SelectList(_context.Course, "Id", "Title");
                ViewData["Studentid"] = new SelectList(_context.Student, "Id", "FullName");
                return(RedirectToAction(nameof(Index)));
            }
            return(View());
        }
Exemple #2
0
        public async Task <IActionResult> Create([Bind("ID,NomeMarca,Linha,Garantia,Nacionalidade,TempoMercado")] Marca marca)
        {
            if (ModelState.IsValid)
            {
                _context.Add(marca);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(marca));
        }
Exemple #3
0
        public async Task <IActionResult> Create([Bind("ID,NomeLivro,Autor,Genero,NPaginas,Prefacio,AnoLivro")] Biblioteca biblioteca)
        {
            if (ModelState.IsValid)
            {
                _context.Add(biblioteca);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(biblioteca));
        }
Exemple #4
0
        public async Task <IActionResult> Create([Bind("ID,NomeCarro,Modelo,Ano,Cor,Combustivel")] Carros carros)
        {
            if (ModelState.IsValid)
            {
                _context.Add(carros);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(carros));
        }
        public async Task <IActionResult> Create([Bind("Id,Title,Credits,Semester,Programme,EducationLevel,FirstTeacherId,SecondTeacherId")] Course course)
        {
            if (ModelState.IsValid)
            {
                _context.Add(course);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["FirstTeacherId"]  = new SelectList(_context.Teacher, "Id", "FullName", course.FirstTeacherId);
            ViewData["SecondTeacherId"] = new SelectList(_context.Teacher, "Id", "FullName", course.SecondTeacherId);
            return(View(course));
        }
        public async Task <IActionResult> Create(TeacherViewModel model)
        {
            if (ModelState.IsValid)
            {
                string  uniqueFileName = UploadedFile(model);
                Teacher teacher        = new Teacher
                {
                    FirstName      = model.FirstName,
                    LastName       = model.LastName,
                    Degree         = model.Degree,
                    AcademicRank   = model.AcademicRank,
                    OfficeNumber   = model.OfficeNumber,
                    HireDate       = model.HireDate,
                    ProfilePicture = uniqueFileName,
                };
                _context.Add(teacher);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View());
        }
Exemple #7
0
        public async Task <IActionResult> Create(StudentViewModel model)
        {
            if (ModelState.IsValid)
            {
                string  uniqueFileName = UploadedFile(model);
                Student student        = new Student
                {
                    FirstName       = model.FirstName,
                    LastName        = model.LastName,
                    IndexId         = model.IndexId,
                    EducationLevel  = model.EducationLevel,
                    AcquiredCredits = model.AcquiredCredits,
                    CurrentSemestar = model.CurrentSemestar,
                    EnrollmentDate  = model.EnrollmentDate,
                    ProfilePicture  = uniqueFileName,
                };
                _context.Add(student);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View());
        }