コード例 #1
0
ファイル: EditEmployee.razor.cs プロジェクト: minkione/HES
        public async Task OnCompanyChangeAsync(ChangeEventArgs args)
        {
            var companyId = (string)args.Value;

            if (companyId == string.Empty)
            {
                Employee.DepartmentId = null;
            }

            Departments = await OrgStructureService.GetDepartmentsByCompanyIdAsync(companyId);

            Employee.DepartmentId = Departments.FirstOrDefault()?.Id;
        }
コード例 #2
0
        protected override async Task OnInitializedAsync()
        {
            try
            {
                EmployeeService     = ScopedServices.GetRequiredService <IEmployeeService>();
                OrgStructureService = ScopedServices.GetRequiredService <IOrgStructureService>();

                ModalDialogService.OnCancel += ModalDialogService_OnCancel;

                Employee = await EmployeeService.GetEmployeeByIdAsync(EmployeeId);

                if (Employee == null)
                {
                    throw new Exception("Employee not found.");
                }

                EntityBeingEdited = MemoryCache.TryGetValue(Employee.Id, out object _);
                if (!EntityBeingEdited)
                {
                    MemoryCache.Set(Employee.Id, Employee);
                }

                Companies = await OrgStructureService.GetCompaniesAsync();

                if (Employee.DepartmentId == null)
                {
                    Departments = new List <Department>();
                }
                else
                {
                    Departments = await OrgStructureService.GetDepartmentsByCompanyIdAsync(Employee.Department.CompanyId);
                }

                Positions = await OrgStructureService.GetPositionsAsync();

                SetInitialized();
            }
            catch (Exception ex)
            {
                Logger.LogError(ex.Message);
                SetLoadFailed(ex.Message);
                await ToastService.ShowToastAsync(ex.Message, ToastType.Error);

                await ModalDialogService.CancelAsync();
            }
        }
コード例 #3
0
        protected override async Task OnInitializedAsync()
        {
            try
            {
                WorkstationService  = ScopedServices.GetRequiredService <IWorkstationService>();
                OrgStructureService = ScopedServices.GetRequiredService <IOrgStructureService>();
                RemoteWorkstationConnectionsService = ScopedServices.GetRequiredService <IRemoteWorkstationConnectionsService>();

                Workstation = await WorkstationService.GetWorkstationByIdAsync(WorkstationId);

                if (Workstation == null)
                {
                    throw new Exception("Workstation not found.");
                }

                ModalDialogService.OnCancel += OnCancel;

                EntityBeingEdited = MemoryCache.TryGetValue(Workstation.Id, out object _);
                if (!EntityBeingEdited)
                {
                    MemoryCache.Set(Workstation.Id, Workstation);
                }

                Companies = await OrgStructureService.GetCompaniesAsync();

                if (Workstation.DepartmentId == null)
                {
                    Departments = new List <Department>();
                }
                else
                {
                    Departments = await OrgStructureService.GetDepartmentsByCompanyIdAsync(Workstation.Department.CompanyId);
                }

                SetInitialized();
            }
            catch (Exception ex)
            {
                Logger.LogError(ex.Message);
                await ToastService.ShowToastAsync(ex.Message, ToastType.Error);

                await ModalDialogService.CancelAsync();
            }
        }
コード例 #4
0
ファイル: CreateEmployee.razor.cs プロジェクト: minkione/HES
        private async Task CompanyChangedAsync(ChangeEventArgs args)
        {
            Departments = await OrgStructureService.GetDepartmentsByCompanyIdAsync(args.Value.ToString());

            Employee.DepartmentId = Departments.FirstOrDefault()?.Id;
        }