public IActionResult UpdateDepartmentData(long Id) { if (Id.Equals(0)) { ViewBag.ErrorMessage = $"The Department with Id { Id } could not be found"; return(View("NotFound")); } else { Department department = entityRepository.GetById(Id); if (department == null) { ViewBag.ErrorMessage = $"The Department with Id { Id } could not be found"; return(View("NotFound")); } UpdateDepartmentViewModel model = new UpdateDepartmentViewModel { Id = department.Id, DepartmentCode = department.DepartmentCode, DepartmentName = department.DepartmentName, FacultyId = department.FacultyId }; GetAllFaculties(model); return(PartialView(model)); } }
public async Task <IActionResult> OnGetAsync(int departmentId) { try { DepartmentDetailsViewModel departmentDetailsViewModel = await _departmentService.GetDepartmentAsync(departmentId); if (departmentDetailsViewModel == null) { return(NotFound()); } UpdateDepartmentViewModel = new UpdateDepartmentViewModel() { DepartmentId = departmentDetailsViewModel.DepartmentId, DepartmentName = departmentDetailsViewModel.DepartmentName, Description = departmentDetailsViewModel.Description, }; } catch (Exception) { ErrorMessage = "There is some problem with the service. Please try again. If the problem persists then contract with the system administrator."; } return(Page()); }
public async Task <HttpResponseMessage> UpdateAsync(UpdateDepartmentViewModel updateDepartmentViewModel) { updateDepartmentViewModel.ThrowIfNull(nameof(updateDepartmentViewModel)); HttpResponseMessage response = await _httpClient .PutAsJsonAsync($"v1/departments/{updateDepartmentViewModel.DepartmentId}", updateDepartmentViewModel); return(response); }
public async Task UpdateDepartmentAsync(UpdateDepartmentViewModel updateDepartmentViewModel) { string jsonString = JsonSerializer.Serialize(updateDepartmentViewModel); using StringContent stringContent = new StringContent(jsonString, Encoding.UTF8, "application/json"); HttpResponseMessage response = await _httpClient.PutAsync("department/update-department", stringContent); if (!response.IsSuccessStatusCode) { throw new ApplicationException($"{response.ReasonPhrase}: The status code is: {(int)response.StatusCode}"); } }
protected override async Task OnInitializedAsync() { DepartmentDetailsViewModel departmentDetailsViewModel = await _departmentService.GetByIdAsync(DepartmentId); if (departmentDetailsViewModel == null) { ErrorMessage = "Employee with provided id does not exists!"; } UpdateDepartmentModel = new UpdateDepartmentViewModel() { DepartmentId = departmentDetailsViewModel.DepartmentId, DepartmentName = departmentDetailsViewModel.DepartmentName, Description = departmentDetailsViewModel.Description, }; }
public IActionResult UpdateDepartmentData(UpdateDepartmentViewModel model) { if (ModelState.IsValid) { Department department = entityRepository.GetById(model.Id); if (department == null) { ViewBag.ErrorMessage = $"The Department with Id { model.Id } could not be found"; return(View("NotFound")); } department.DepartmentCode = model.DepartmentCode; department.DepartmentName = model.DepartmentName; department.FacultyId = model.FacultyId; entityRepository.Update(department); entityRepository.Save(); return(Json(new { success = true })); } GetAllFaculties(model); return(PartialView(model)); }
public async Task <IActionResult> UpdateDepartment(UpdateDepartmentViewModel model) { Result result = new Result(); try { result = await _maintenanceService.UpdateDepartment(_mapper.Map <UpdateDepartmentDTO>(model)); //redirect to user list after update of field if (result.Success) { result.IsRedirect = true; result.RedirectUrl = "Maintenance/Department"; } } catch (Exception e) { _logger.LogError("Error calling UpdateDepartment: {0}", e.Message); } return(Json(result)); }
public UpdateDepartmentWindow(Node node, Department department) { InitializeComponent(); DataContext = new UpdateDepartmentViewModel(node, department); }