Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Include examples of how to send form data to e.g. back-ends #49

Open
KrisJanssen opened this issue Mar 14, 2021 · 1 comment
Open

Include examples of how to send form data to e.g. back-ends #49

KrisJanssen opened this issue Mar 14, 2021 · 1 comment

Comments

@KrisJanssen
Copy link

Hi guys,

Forge seems to be a very nice and potentially useful project. The fact that the demo apps are included to not only demonstrate Forms but also the application piece (e.g. the routing) is nice.

However, coming from creating monolithic WinForms based applications, I struggle to infer how I would achieve something like adopting the codebase to e.g. do CRUD operations on any kind of storage (a DB, Sharepoint, ...). It is not so much the interaction with these back end that is a problem but rather how to create e.g. a service and then properly register that so the forms can leverage it.

A sort of dummy example here would be extremely helpful.

@edongashi
Copy link
Collaborator

Hi @KrisJanssen!

The fact that the demo apps are included to not only demonstrate Forms but also the application piece (e.g. the routing) is nice.

I'm glad you found it useful. Though the application "framework" is not something I'd use in production as a dependency because it's stiff and opinionated. As you have noticed, it relies on a DI engine like NInject and other stuff, which is a bad design smell. Instead, I'd take some parts I like and simply add organize those in my project and fit them as needed.

Sadly the same goes for Forge.Forms. It relies on big UI toolkits and is a pain to manage dependencies.

It is not so much the interaction with these back end that is a problem but rather how to create e.g. a service and then properly register that so the forms can leverage it.

Are you using the MVVM pattern for your app? If you're using that, then your form model can raise actions and your ViewModel should handle actions by implementing IActionHandler. It should look like this:

class MyViewModel : INotifyPropertyChanged, IActionHandler
{
    // Suppose we have the DB from somewhere...
    public IDatabase Database { get; set; }

    public void HandleAction(IActionContext actionContext)
    {
        if (actionContext.Action is "save")
        {
            MyFormModel model = (MyFormModel)actionContext.Model;
            this.Database.Save(model);
        }
    }
  
    ...
}

I'm not sure if this is what you have asked. Please let me know if you need further explanation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants