Click here to Skip to main content
15,896,359 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more: , +
Hi guys,

I'm in the middle of creating a desktop application that allows a user to insert their Organisation details into a database that uses Entity Framework.

So far, I've created CRUD operations to allow the user to add, delete and update data, which was straight forward.

When doing this, I'm using commands, as I am trying to use the MVVM design pattern.

But what I want to achieve is to allow the user to only enter one row of data into the database, so what would be the best way to achieve it?

I've looked at using a Flag as well as using a query. Here is the code I have currently;

C#
private ICommand showAddCommand;
            public ICommand ShowAddCommand
            {
                get
                {
                    if (this.showAddCommand == null)
                    {
                        this.showAddCommand = new RelayCommand(this.SaveFormExecute, this.SaveFormCanExecute);
                    }
                    return this.showAddCommand;
                }
            }

            private bool SaveFormCanExecute()
            {
                return !string.IsNullOrEmpty(OrganisationName) //...
            }

            private void SaveFormExecute()
            {
                InsertOrganisations();
            }


so what would be the best way to do this? Any help will be appreciated.

Many thanks,

Greg.
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900