Simlicity is not always so great…

While making some changes to the skills on my website I noticed a design flaw that I created while simplifying some display options.


public async Task<ActionResult> Index()
{

&nbsp;

Dictionary<string, List<Skill>> skillDictionary = await db.Skills
.GroupBy(s => s.SkillGroup)
.ToDictionaryAsync(g => g.Key, g => g.OrderBy(v=>(int)v.SkillLevel).ToList());

ViewBag.GroupedSkills = skillDictionary;
return View();
}

Super simple ey? Yes but one fatal flaw, I cannot sort the skill groups this way… This needs fixing pronto, two solutions I came up with:

  1. Adding an OrderBy and in the ordering, function pass a lambda expression to order the skill groups by the amount of ‘Advanced’ skills
  2. Adding two new Entities:
    1. SkillGroup
    2. SkillToGroupAssigement

While migrating the whole database and is always a bit scary I think I’ll go for option two it’s a lot more long lasting and allows me to custom sort Skill Groups.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s