Esempio n. 1
0
        public async Task <IActionResult> Edit(int id, [Bind("ExamPrice,Id,Surname,Name,Patronymic,Photo,PhotoPath")] ExaminerViewModel examinerViewModel)
        {
            if (id != examinerViewModel.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                Examiner examiner = new Examiner
                {
                    Id         = examinerViewModel.Id,
                    Surname    = examinerViewModel.Surname,
                    Name       = examinerViewModel.Name,
                    Patronymic = examinerViewModel.Patronymic,
                    ExamPrice  = examinerViewModel.ExamPrice,
                    Photo      = examinerViewModel.PhotoPath
                };

                if (examinerViewModel.Photo != null)
                {
                    var fileName = UploadedFile(examinerViewModel);
                    examiner.Photo = fileName;
                }

                _context.Update(examiner);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(examinerViewModel));
        }
Esempio n. 2
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,Mark,Date,EnrolleeId,ExaminerId,DisciplineId")] Exam exam)
        {
            if (id != exam.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(exam);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!ExamExists(exam.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }

            LoadSelectLists(exam.DisciplineId, exam.EnrolleeId, exam.ExaminerId);

            return(View(exam));
        }
Esempio n. 3
0
        public async Task <IActionResult> Edit(int id, [Bind("Address,BirthYear,Passport,Id,Surname,Name,Patronymic,Photo,PhotoPath")] EnrolleeViewModel enrolleeViewModel)
        {
            if (id != enrolleeViewModel.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                Enrollee enrollee = new Enrollee
                {
                    Id         = enrolleeViewModel.Id,
                    Surname    = enrolleeViewModel.Surname,
                    Name       = enrolleeViewModel.Name,
                    Patronymic = enrolleeViewModel.Patronymic,
                    Address    = enrolleeViewModel.Address,
                    BirthYear  = enrolleeViewModel.BirthYear,
                    Passport   = enrolleeViewModel.Passport,
                    Photo      = enrolleeViewModel.PhotoPath
                };

                if (enrolleeViewModel.Photo != null)
                {
                    var fileName = UploadedFile(enrolleeViewModel);
                    enrollee.Photo = fileName;
                }

                _context.Update(enrollee);
                await _context.SaveChangesAsync();

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