Exemple #1
0
    public void ObsoleteApiReturnsEditContextForChaining()
    {
        var editContext = new EditContext(new object());

#pragma warning disable 0618
        var returnValue = editContext.AddDataAnnotationsValidation();
#pragma warning restore 0618
        Assert.Same(editContext, returnValue);
    }
        protected override void OnInit()
        {
            editContext = new EditContext(Person);
            editContext.AddDataAnnotationsValidation();

            // Validate feature areas too.
            editContext.OnFieldChanged        += (sender, e) => ValidateField(e);
            editContext.OnValidationRequested += (sender, e) => ValidateModel();

            stores = new Dictionary <FeatureArea, ValidationMessageStore>();
            for (var i = 0; i < Person.Areas.Count; i++)
            {
                stores.Add(Person.Areas[i], new ValidationMessageStore(editContext));
            }
        }
Exemple #3
0
        public NavigationButtonsUnitTests()
        {
            _context = new TestContext();

            _eventLoggingService = new Mock <IEventLoggingService>();
            _context.Services.AddSingleton(_eventLoggingService.Object);

            _navigationManager = new Mock <Wrappers.INavigationManager>();
            _context.Services.AddSingleton(_navigationManager.Object);

            _model       = new Model();
            _editContext = new EditContext(_model);
            _editContext.AddDataAnnotationsValidation();

            _cut = _context.RenderComponent <NavigationButtons>(parameters =>
                                                                parameters.Add(p => p.PreviousUrl, "https://test.com/previous")
                                                                .Add(p => p.NextUrl, "https://test.com/next")
                                                                .AddCascadingValue(_editContext)
                                                                );
        }
Exemple #4
0
        private async Task HandleSubmit()
        {
            if (_editContext.Validate())
            {
                IsLoadingCircle = true;

                var client = await Http.PostAsJsonAsync(Constants.URI.Berita.Register, new CreateBeritaRequest
                {
                    UserID      = Model.UserID,
                    Title       = Model.Title,
                    Description = Model.Description
                });

                Response = Task.FromResult(await client.Content.ReadFromJsonAsync <ApiResponse <CreateBeritaResponse> >()).Result;

                if (!Response.Status.IsError)
                {
                    await uploadFileAsync(Response.Result.BeritaID, Constants.FileEntityType.Berita);

                    IsLoadingCircle = false;

                    await DialogIsOpenStatus.InvokeAsync(false);

                    await OnSuccessSubmit.InvokeAsync(true);

                    StateHasChanged();
                }
                else
                {
                    Toaster.Add(Response.Status.Message, MatToastType.Danger);

                    IsLoadingCircle = false;
                    StateHasChanged();
                }
            }
            else
            {
                _editContext.AddDataAnnotationsValidation();
                Toaster.AddErrors(_editContext.GetValidationMessages());
            }
        }
Exemple #5
0
 public void InitializeEditContext(EditContext editContext, IServiceProvider serviceProvider)
 {
     editContext.AddDataAnnotationsValidation();
 }
Exemple #6
0
 protected override void OnInitialized()
 {
     EditContext = new EditContext(LoginModel);
     EditContext.AddDataAnnotationsValidation();
     EditContext.AddBootstrapValidationClassProvider();
 }