C# Better logic for viewmodel Any advice on how to make this code; cleaner, more effective, just overall better!
Program setup object that is coming from the database. it loop the object adding to the viewmodel object. Then the object has a certain properties base on type. The config type will only have the setting and value objects.
class Program
{
    static void Main(string[] args)
    {
        //Setting up fake objects
        List&lt;Meeting&gt; meetingList = new List&lt;Meeting&gt;();
        meetingList.Add(new Meeting() { Id =1 ,Name=&quot;a&quot;, Type= &quot;System&quot;  });
        meetingList.Add(new Meeting() { Id = 2, Name = &quot;b&quot;, Type = &quot;System&quot; });
        meetingList.Add(new Meeting() { Id = 3, Name = &quot;c&quot;, Type = &quot;Config&quot;, Setting=&quot;Control&quot;, Value=&quot;2&quot;  });
        meetingList.Add(new Meeting() { Id = 4, Name = &quot;d&quot;, Type = &quot;Config&quot;, Setting = &quot;Control&quot;, Value = &quot;3&quot; });
        meetingList.Add(new Meeting() { Id = 5, Name = &quot;e&quot;, Type = &quot;Config&quot;, Setting = &quot;&quot;, Value = &quot;&quot; });

        //Real Code
        List&lt;Meeting&gt; meetingviewmodel = new List&lt;Meeting&gt;();
        foreach (var meeting in meetingList)
        {
           Meeting mvm = new Meeting();
           meeting.Id = mvm.Id;
           meeting.Name = mvm.Name;
           meeting.Type = mvm.Type;
           if (meeting.Type == &quot;System&quot;)
           {
               meetingviewmodel.Add(mvm);
           }
           if (meeting.Type == &quot;Config&quot; &amp;&amp; meeting.Setting != null)
           {
              meeting.Setting = mvm.Setting;
              meeting.Value = mvm.Value;
              meetingviewmodel.Add(mvm);

            }
        }
    }

    class Meeting
    {
        public int Id { get; set; }
        public string Name { get; set; }
        public string Type { get; set; }
        public string Setting { get; set; }
        public string Value { get; set; }
    }
}
First, I think you've flipped the assigning without noticing that you're assigning null values to the meeting properties (e.g meeting.Id = mvm.Id;) notice that you've already create a new instance of Meeting object, and yet, you replaced the actual values with the new instance values, while you are expected to do the opposite.
So, I assumed you meant to do this mvm.Id = meeting.Id;.
If you need to add the Meeting object to the model based on the Type property. You can do this :
foreach (var meeting in meetingList)
{
    // if this element's Type property is null or empty
    // then skip and go to the next one
    // this condition will be applied on all meeting types 
    if(string.IsNullOrEmpty(meeting.Type)) { continue; }
    
    meetingviewmodel.Add(meeting);  
}

this will add all meeting objects that have defined Type, this will include System and Config types along with any other defined types.
if you only need to add System and Config types  meetings, and ignore the rest, you can do this :
foreach (var meeting in meetingList)
{
    // if you want to only add System &amp; Config meetings 
    // you can use this condition
    if(!string.IsNullOrEmpty(meeting.Type) &amp;&amp; (meeting.Type == &quot;System&quot; || meeting.Type == &quot;Config&quot;))
    {
        meetingviewmodel.Add(meeting);
    }
}

or if you into LINQ :
var meetingviewmodel = meetingList
            .Where(x=&gt; !string.IsNullOrEmpty(x.Type) &amp;&amp; (x.Type == &quot;System&quot; || x.Type == &quot;Config&quot;))
            .ToList();