protected async Task Submit(CreateUserModel model)
        {
            Awaiting = true;
            var result = await UsersApiClient.CreateUser(model);

            if (result)
            {
                NotificationService.Notify(new NotificationMessage
                {
                    Duration = 5000,
                    Severity = NotificationSeverity.Success,
                    Summary  = "User created"
                });
            }
            Awaiting = false;
            var title = Departments.FirstOrDefault(departmentModel => departmentModel.Id == NewUser.DepartmentId)
                        ?.Title;

            DialogService.Close(new UserModel
            {
                Name       = model.User.Name,
                Surname    = model.User.Surname,
                Department = new DepartmentModel
                {
                    Title = title,
                    Id    = NewUser.DepartmentId,
                    Users = new List <UserModel>()
                }
            });
        }
        protected async Task DeleteUser(int userId, DepartmentModel department)
        {
            var result = await UsersApiClient.DeleteUser(userId);

            if (result)
            {
                var user = department.Users.Find(model => model.Id == userId);
                NotificationService.Notify(new NotificationMessage
                {
                    Summary  = $"{user.Name} {user.Surname} deleted",
                    Duration = 5000,
                    Severity = NotificationSeverity.Info
                });
                department.Users.Remove(user);
                await InvokeAsync(StateHasChanged);
            }
        }
Ejemplo n.º 3
0
        public App()
        {
            try
            {
                this._tokenProvider = new TokenProvider(
                    ConfigurationManager.AppSettings["AuthAPI"], 28);

                this._usersApiClient = new UsersApiClient(ConfigurationManager.AppSettings["UsersAPI"]);

                this._examsApiClient = new ExamsApiClient(ConfigurationManager.AppSettings["ExamsAPI"]);

                this.ConfigureHandlers();

                this._isReadyForStartup = true;
            }
            catch (Exception ex)
            {
                this._isReadyForStartup = false;
            }
        }
Ejemplo n.º 4
0
 public void SetUp()
 {
     _client = new UsersApiClient(ClientFactory,
                                  Logger.None, default);
 }
Ejemplo n.º 5
0
 private async Task LoadData()
 {
     Users         = new List <UserModel>(await UsersApiClient.GetUsers());
     IsInitialized = true;
 }