protected override async Task OnInitializedAsync() { Saved = false; Countries = (await CountryDataService.GetAllCountries()).ToList(); //Employee = await EmployeeDataService.GetEmployeeDetails(int.Parse(EmployeeId)); JobCategories = (await JobCategoryDataService.GetAllJobCategories()).ToList(); int.TryParse(EmployeeId, out var employeeId); var savedEmployee = await LocalStorageService.GetAsync <Employee>("Employee"); if (savedEmployee != null && employeeId == 0) { Employee = savedEmployee; } else if (employeeId == 0) //new employee is being created { //add some defaults Employee = new Employee { CountryId = 1, JobCategoryId = 1, BirthDate = DateTime.Now, JoinedDate = DateTime.Now }; } else { Employee = await EmployeeDataService.GetEmployeeDetails(int.Parse(EmployeeId)); } CountryId = Employee.CountryId.ToString(); JobCategoryId = Employee.JobCategoryId.ToString(); }
protected async override Task OnInitializedAsync() { CurrentState.IsSaved = false; Countries = (await CountryDataService.GetAll()).ToList(); JobCategories = (await JobCategoryDataService.GetAll()).ToList(); int.TryParse(EmployeeId, out int id); if (id == 0) { Employee = new Employee { CountryId = 1, JobCategoryId = 1, BirthDate = DateTime.Now, JoinedDate = DateTime.Now }; } else { Employee = await EmployeeDataService.GetDetail(id); } CountryId = Employee.CountryId.ToString(); JobCategoryId = Employee.JobCategoryId.ToString(); }
protected async Task HandleValidSubmit() { if (JobCategory.JobCategoryId == 0) //new { var addedJobCategory = await JobCategoryDataService.AddJobCategory(JobCategory); if (addedJobCategory != null) { StatusClass = "alert-success"; Message = "New Job Category added successfully."; Saved = true; } else { StatusClass = "alert-danger"; Message = "Something went wrong adding the new Job Category. Please try again."; Saved = false; } } else { await JobCategoryDataService.UpdateJobCategory(JobCategory); StatusClass = "alert-success"; Message = "Job Category updated successfully."; Saved = true; } }
protected override async Task OnInitializedAsync() { Saved = false; Countries = (await CountryDataService.GetAllCountries()).ToList(); JobCategories = (await JobCategoryDataService.GetAllJobCategories()).ToList(); int.TryParse(EmployeeId, out var employeeId); if (employeeId == 0) //new employee is being created { // I kursen lades denna överst i den yttre if-satsen, // men det blir ju knas om man går in och redigerar en befintlig anställd if (EmployeeDataService.SavedEmployee != null) { Employee = EmployeeDataService.SavedEmployee; } else { //add some defaults Employee = new Employee { CountryId = 1, JobCategoryId = 1, BirthDate = DateTime.Now, JoinedDate = DateTime.Now }; } } else { Employee = await EmployeeDataService.GetEmployeeDetails(int.Parse(EmployeeId)); } CountryId = Employee.CountryId.ToString(); JobCategoryId = Employee.JobCategoryId.ToString(); }
protected override async Task OnInitializedAsync() { Saved = false; Countries = await CountryDataService.GetAllCountries(); JobCategories = await JobCategoryDataService.GetAllJobCategories(); int.TryParse(EmployeeId, out var employeeId); if (employeeId == 0) { // New employee Employee = new Employee { CountryId = 1, JobCategoryId = 1, BirthDate = DateTime.Now, JoinedDate = DateTime.Now }; } else { Employee = await EmployeeDataService.GetEmployeeDetails(int.Parse(EmployeeId)); } CountryId = Employee.CountryId.ToString(); JobCategoryId = Employee.JobCategoryId.ToString(); }
protected async override Task OnInitializedAsync() { Saved = false; Countries = (await CountryDataService.GetAllCountries()).ToList(); JobCategories = (await JobCategoryDataService.GetAllJobCategories()).ToList(); if (!string.IsNullOrWhiteSpace(EmployeeId)) { Employee = await EmployeeDataService.GetEmployeeDetails(int.Parse(EmployeeId)); } else { Employee = new Employee { CountryId = 2, JobCategoryId = 2, BirthDate = DateTime.Now.AddYears(-30), JoinedDate = DateTime.Now, } }; CountryId = Employee.CountryId.ToString(); JobCategoryId = Employee.JobCategoryId.ToString(); }
protected override async Task OnInitializedAsync() { Saved = false; Countries = (await CountryDataService.GetAllCountries()).ToList(); JobCategories = (await JobCategoryDataService.GetAllJobCategories()).ToList(); int.TryParse(EmployeeId, out var employeeId); if (employeeId == 0) // new employee is being created { // add some defaults Employee = new Employee { CountryId = 1, JobCategoryId = 1, BirthDate = DateTime.Now }; } else { Employee = await EmployeeDataService.GetEmployeeDetails(employeeId); } CountryId = Employee.CountryId.ToString(); JobCategoryId = Employee.JobCategoryId.ToString(); }
protected override async Task OnInitializedAsync() { Saved = false; Cities = (await CityDataService.GetAllCities()).ToList(); Countries = (await CountryDataService.GetAllCountries()).ToList(); JobCategories = (await JobCategoryDataService.GetAllJobCategories()).ToList(); Offices = (await OfficeDataService.GetAllOffices()).ToList(); Pods = (await PodDataService.GetAllPods()).ToList(); Regions = (await RegionDataService.GetAllRegions()).ToList(); int.TryParse(EmployeeId, out var employeeId); if (employeeId == 0) //new employee is being created { //add some defaults Employee = new Employee { OfficeId = 1, JobCategoryId = 1, RegionId = 3 }; } else { Employee = await EmployeeDataService.GetEmployeeDetails(int.Parse(EmployeeId)); } OfficeId = Employee.OfficeId.ToString(); RegionId = Employee.RegionId.ToString(); PodId = Employee.PodId.ToString(); JobCategoryId = Employee.JobCategoryId.ToString(); }
protected async Task DeleteJobCategory() { await JobCategoryDataService.DeleteJobCategory(JobCategory.JobCategoryId); StatusClass = "alert-success"; Message = "Deleted successfully"; Saved = true; }
protected override async Task OnInitializedAsync() { Countries = (await CountryDataService.GetAllCountries()).ToList(); JobCategories = (await JobCategoryDataService.GetAllJobCategories()).ToList(); Employee = int.TryParse(EmployeeId, out var parsedEmployeeId) ? await EmployeeDataService.GetEmployeeDetails(parsedEmployeeId) : CreateDefaultEmployee(); CountryId = Employee.CountryId.ToString(); JobCategoryId = Employee.JobCategoryId.ToString(); }
protected override async Task OnInitializedAsync() { Employee = await EmployeeDataService.GetEmployeeDetails(int.Parse(EmployeeId)); MapMarkers = new List <Marker> { new Marker { Description = $"{Employee.FirstName} {Employee.LastName}", ShowPopup = false, X = Employee.Longitude, Y = Employee.Latitude } }; JobCategory = (await JobCategoryDataService.GetJobCategoryById(Employee.JobCategoryId)).JobCategoryName; }
protected override async Task OnInitializedAsync() { Saved = false; Countries = (await CountryDataService.GetAllCountries()).ToList(); JobCategories = (await JobCategoryDataService.GetAllJobCategories()).ToList(); int.TryParse(EmployeeId, out var employeeId); if (employeeId != 0) //new employee is being created { Employee = await EmployeeDataService.GetEmployeeDetails(int.Parse(EmployeeId)); } }
protected override async Task OnInitializedAsync() { Saved = false; Employee = EmployeeId == 0 ?new Employee { CountryId = 1, JobCategoryId = 1, BirthDate = DateTime.Now, JoinedDate = DateTime.Now } :await EmployeeDataService.GetEmployeeDetails(EmployeeId); Countries = await CountryDataService.GetAllCountries(); JobCategories = await JobCategoryDataService.GetAllJobCategories(); }
protected override async Task OnInitializedAsync() { Saved = false; if (JobCategoryId == 0) //new Job Category is being created { //add some defaults JobCategory = new JobCategory(); } else { JobCategory = await JobCategoryDataService.GetJobCategoryById(JobCategoryId); } }
protected override async Task OnInitializedAsync() { Saved = false; //Employee = await EmployeeDataService.GetEmployeeDetails(int.Parse(EmployeeId)); Countries = (await CountryDataService.GetAllCountries()).ToList(); JobCategories = (await JobCategoryDataService.GetAllJobCategories()).ToList(); int.TryParse(EmployeeId, out var employeeId); if (employeeId == 0) { } else { Employee = await EmployeeDataService.GetEmployeeDetails(int.Parse(EmployeeId)); } CountryId = Employee.CountryId.ToString(); JobCategoryId = Employee.JobCategoryId.ToString(); }
protected override async Task OnInitializedAsync() { Saved = false; Countries = (await CountryDataService.GetAllCountries()).OrderBy(o => o.Name).ToList(); JobCategories = (await JobCategoryDataService.GetAllJobCategories()).ToList(); if (EmployeeId == 0) //new employee is being created { //add some defaults Employee = new Employee { CountryId = 1, JobCategoryId = 1, BirthDate = DateTime.Now.AddYears(-18), JoinedDate = DateTime.Now.Date }; } else { Employee = await EmployeeDataService.GetEmployeeDetails(EmployeeId); } CountryId = Employee.CountryId.ToString(); JobCategoryId = Employee.JobCategoryId.ToString(); }
protected override async Task OnInitializedAsync( ) { Saved = false; Countries = (await CountryDataService.GetAllCountries( )).ToList( ); JobCategories = (await JobCategoryDataService.GetAllJobCategories( )).ToList( ); if (!int.TryParse(EmployeeID, out int employeeID)) { Employee = new Employee { CountryId = 1, JobCategoryId = 1, BirthDate = DateTime.Now } } ; else { Employee = await EmployeeDataService.GetEmployeeDetails(employeeID); } CountryID = Employee.CountryId.ToString( ); JobCategoryID = Employee.JobCategoryId.ToString( ); await base.OnInitializedAsync( ); }
protected override async Task OnInitializedAsync() { Saved = false; Countries = await CountryDataService.GetAllCountries(); JobCategories = await JobCategoryDataService.GetAllJobCategories(); if (EmployeeId == 0) { Employee = new Employee { CountryId = 1, JobCategoryId = 1, BirthDate = DateTime.Now, JoinedDate = DateTime.Now } } ; else { Employee = await EmployeeDataService.GetEmployeeDetails(EmployeeId); } JobCategoryId = Employee.JobCategoryId.ToString(); CountryId = Employee.CountryId.ToString(); }
protected override async Task OnInitializedAsync() { // Employee = await EmployeeDataService.GetEmployeeDetails(Convert.ToInt32(EmployeeId)); Countries = await CountryDataService.GetAllCountries(); JobCategories = await JobCategoryDataService.GetAllJobCategories(); int.TryParse(EmployeeId, out var id); if (id == 0) { Employee = new Employee { CountryId = 1, JobCategoryId = 1, BirthDate = DateTime.Now }; } else { Employee = await EmployeeDataService.GetEmployeeDetails(Convert.ToInt32(EmployeeId)); } CountryId = Employee.CountryId.ToString(); JobCategoryId = Employee.JobCategoryId.ToString(); await base.OnInitializedAsync(); }
protected override async Task OnInitializedAsync() { int.TryParse(EmployeeId, out int employeeId); //Employee = await EmployeeDataService.GetEmployeeDetails(int.Parse(EmployeeId)); if (employeeId == 0) //new employee is being created { //add some defaults Employee = new Employee { CountryId = 1, JobCategoryId = 1, BirthDate = DateTime.Now, JoinedDate = DateTime.Now }; EmployeeId = 0.ToString(); } else { Employee = await EmployeeDataService.GetEmployeeDetails(int.Parse(EmployeeId)); } Countries = await CountryDataService.GetAllCountries(); CountryId = Employee.CountryId.ToString(); JobCategories = await JobCategoryDataService.GetAllJobCategories(); JobCategoryId = Employee.JobCategoryId.ToString(); }
protected override async Task OnInitializedAsync() { JobCategory = await JobCategoryDataService.GetJobCategoryById(JobCategoryId); }
protected override async Task OnInitializedAsync() { JobCategories = (await JobCategoryDataService.GetAllJobCategories()).ToList(); JobCategoryId = Employee.JobCategoryId.ToString(); }