Create a model representation C# from this example screenshot

yguyon28
yguyon28 used Ask the Experts™
on
I would like to get some feedback on what is the best way to create a model from this screen representation that I have attached bellow. I created a class GeneralSetupCompanyParame and I'm not sure how I should declare each property that I have circled in yellow in my screenShot. The one for the English,Spanish, French Description...

I'm just looking for the best representation. I started creating my company class, I'm just missing how I will set my property for the English,Spanish and French Description.

 public class GeneralSetupCompanyParameters
    {

         public class SMTPSettings
        {
            public string CommonSMTPSettings { get; set; }
            public string SMTPServer { get; set; }
            public int SMTPPort { get; set; }
        }
        
        public string CountryName { get; set; }

        public string ServiceYear { get; set; }
        public string QuickNote { get; set; }
        public bool AllowFutureSaleDates { get; set; }
        public bool ForcePWComplexity { get; set; }
        public bool AppointmentNotification { get; set; }
        public bool LimitPastSaleDates { get; set; }
        public int LimitPastSaleDatesDay { get; set; }
        public bool ForcePeriodicPWChanges { get; set; }
        public bool LockCallLogEntries { get; set; }
        public string EveryDay { get; set; }
        public bool LimitPastCancelDates { get; set; }
        public string LimitPasCancelDatesDays { get; set; }
        public bool CallLogOutcome { get; set; }
    }
}

Open in new window

Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®

Author

Commented:
If there any other comment on how I created my model on something that I did not do correctly please let me know so...
Most Valuable Expert 2018
Distinguished Expert 2018
Commented:
Just a guess really (without knnow more details), but you could create a class that represents a row:

class Language
    bool Use
    int Order
    string English
    string Spanish
    string French

And then add a new property to your GeneralSetupCompanyParameters:

    ICollection<Language> Languages

This list will just be a collection of Language instances:

language = new Language { Use = true, Order = 1, English = "Some Text" ... }
company.Languages.Add(language)
Commented:
Use a list and keep your options, in this list.  You could then have a property in your class which sets the language for all options using an Enum, You could make the Enum flagged so that multiple languages could be supported; e.g. -
class GeneralSetupCompanyParameters
{
	public Language Language { get; set; }
	public List<Option> Options { get; set; }
}

class Option
{
	public bool Active { get; set; }
	public string Name { get; set; }
	public string Description { get; set; }
}

[Flags]
enum Language : int
{
	English = 0,
	Spanish = 1,
	French = 1 << 1
}

Open in new window

If you want to make it so that each 'Option' supports it's own language settings, use an attribute instead of a single class property; e.g. -
class GeneralSetupCompanyParameters
{
	public List<Option> Options { get; set; }
}

[Language(Language = Language.English | Language.French)]
class Option
{
	public bool Active { get; set; }
	public string Name { get; set; }
	public string Description { get; set; }
}

[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property)]
class LanguageAttribute : Attribute
{
	public Language Language { get; set; }
}

[Flags]
enum Language : int
{
	English = 0,
	Spanish = 1,
	French = 1 << 1
}

Open in new window

-saige-

Author

Commented:
Thank you, also do you believe my other properties are declared correctly.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial