Exemple #1
0
 public CreateItemFormViewModel(CreateItemOptions createItemOptions)
 {
     this.createItemOptions = createItemOptions ?? throw new ArgumentNullException(nameof(createItemOptions));
     Model       = Activator.CreateInstance(typeof(TModel)) as TModel;
     EditContext = new EditContext(Model);
     EditContext.OnFieldChanged += OnFieldChanged;
 }
Exemple #2
0
        public virtual EntityTypeBuilder <TEntity> AllowCreateItem <TCreateItem>(Action <CreateItemOptions> configureCreateItem = null)
        {
            var createItemOptions = new CreateItemOptions();

            configureCreateItem?.Invoke(createItemOptions);
            createItemOptions.ItemType = typeof(TCreateItem);

            Builder.AllowCreateItem(createItemOptions);

            return(this);
        }
Exemple #3
0
        public virtual EntityTypeBuilder <TEntity> AllowCreateItem <TCreateModel, TOutputDto>(Action <CreateItemOptions> configureCreateItem = null)
        {
            var createItemOptions = new CreateItemOptions();

            configureCreateItem?.Invoke(createItemOptions);
            createItemOptions.ModelType     = typeof(TCreateModel);
            createItemOptions.OutputDtoType = typeof(TOutputDto);

            Builder.AllowCreateItem(createItemOptions);

            return(this);
        }
Exemple #4
0
        public async Task <TOutputDto> CreateItem(TModel model, CreateItemOptions createItemOptions, CancellationToken cancellationToken = default)
        {
            try
            {
                var response = await _httpClient.PostJsonAsync <TOutputDto>(createItemOptions.CreateUri, model);

                return(response);
            }
            catch (Exception ex)
            {
                _logger.LogError($"Error during creating item for [{createItemOptions.CreateUri}]. Ex: {ex}");

                throw;
            }
        }
        public async Task <TOutputDto> CreateItem(TModel model, CreateItemOptions createItemOptions, CancellationToken cancellationToken = default)
        {
            if (string.IsNullOrWhiteSpace(createItemOptions.CreateUri))
            {
                throw new ArgumentException("If you want use create item feature, you must provide Api endpoint url");
            }

            try
            {
                var response = await httpClient.PostJsonAsync <TOutputDto>(createItemOptions.CreateUri, model);

                return(response);
            }
            catch (Exception ex)
            {
                logger.LogError($"Error during creating item for [{createItemOptions.CreateUri}]. Ex: {ex}");

                throw;
            }
        }
 public bool AllowCreateItem(CreateItemOptions createItemOptions)
 => HasAnnotation(GridViewAnnotationNames.CreateItemOptions, createItemOptions);
 public Task <TOutputDto> CreateItem(TModel model, CreateItemOptions createItemOptions, CancellationToken cancellationToken = default)
 => Task.FromResult(Activator.CreateInstance <TOutputDto>());
Exemple #8
0
 public CreateItemContext(CreateItemOptions createItemOptions, CreateFormCssClasses createFormCssClasses)
 {
     CreateItemOptions    = createItemOptions ?? throw new ArgumentNullException(nameof(createItemOptions));
     CreateFormCssClasses = createFormCssClasses ?? new DefaultCreateFormCssClasses();
 }
Exemple #9
0
 public static bool IsSet(this CreateItemOptions options, CreateItemOptions flags)
 {
     return((options & flags) == flags);
 }