public async Task <IActionResult> OnGetAsync(int employeeId)
        {
            EmployeeDetailsViewModel employeeDetailsViewModel = await _employeeService.GetEmployeeDetailsAsync(employeeId);

            if (employeeDetailsViewModel == null)
            {
                return(NotFound());
            }

            UpdateEmployeeViewModel = new UpdateStudentViewModel()
            {
                EmployeeId   = employeeDetailsViewModel.EmployeeId,
                EmployeeName = employeeDetailsViewModel.EmployeeName,
                DepartmentId = employeeDetailsViewModel.DepartmentId,
                DateOfBirth  = employeeDetailsViewModel.DateOfBirth,
                Email        = employeeDetailsViewModel.Email,
                PhoneNumber  = employeeDetailsViewModel.PhoneNumber
            };

            SelectList items = await _departmentService.GetDepartmentSelectListAsync(employeeDetailsViewModel.DepartmentId);

            DepartmentSelectList = items;

            return(Page());
        }
        public async Task UpdateStudentAsync(UpdateStudentViewModel updateStudentViewModel)
        {
            string jsonStringBody = JsonSerializer.Serialize(updateStudentViewModel);

            using StringContent content = new StringContent(jsonStringBody, Encoding.UTF8, "application/json");
            HttpResponseMessage response = await _httpClient.PutAsync("student/update-student", content);

            if (!response.IsSuccessStatusCode)
            {
                throw new ApplicationException($"{response.ReasonPhrase}: The status code is: {(int)response.StatusCode}");
            }
        }
Esempio n. 3
0
 public ActionResult UpdateProfileForStudent(UpdateStudentViewModel model)
 {
     if (ModelState.IsValid)
     {
         Student student = db.Students.First(s => s.Id.Equals(model.Id));
         student.FirstName   = model.FirstName;
         student.LastName    = model.LastName;
         student.ImageURL    = model.ImageURL;
         student.Description = model.Description;
         student.City        = model.City;
         student.Module      = db.Modules.FirstOrDefault(m => m.Name.Equals(model.selectedModule));
         db.SaveChanges();
         return(RedirectToAction("ViewStudent", "Students", new { id = model.Id }));
     }
     return(View(model));
 }
Esempio n. 4
0
        public ActionResult UpdateProfileForStudent()
        {
            string  userId  = User.Identity.GetUserId();
            Student student = db.Students.FirstOrDefault(s => s.UserId.Equals(userId));
            UpdateStudentViewModel model = new UpdateStudentViewModel()
            {
                FirstName   = student.FirstName,
                LastName    = student.LastName,
                City        = student.City,
                Id          = student.Id,
                Modules     = db.Modules.Select(s => s.Name).ToList(),
                Description = student.Description,
                ImageURL    = student.ImageURL
            };

            return(View(model));
        }