Skip to content

Instantly share code, notes, and snippets.

@berkdulger
Last active January 14, 2020 12:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save berkdulger/5b54fe2e88f295b392013c20b547fe9a to your computer and use it in GitHub Desktop.
Save berkdulger/5b54fe2e88f295b392013c20b547fe9a to your computer and use it in GitHub Desktop.
Code Review for a Sample C# Code
public IEnumerable<GitHubUser> FavoritesList()
{
CookieHelper cookieHelper = new CookieHelper(this.HttpContext);
HttpCookie httpCookie = cookieHelper.SetAndGetHttpCookies();
MyCookie myCookie = new MyCookie()
{
ID = Convert.ToInt32(httpCookie["userId"])
};
List<GitUser> favoritesList = new List<GitUser>();
using (var db = new GitHubContext())
{
var results = (from ch in db.CookiesHistory
where ch.UserId == myCookie.ID
select new { GitUserId = ch.GitUserId });
foreach (var result in results)
{
var user = (from u in db.GitUsers
where u.Id == result.GitUserId
select new { u }).First();
favoritesList.Add(user.u);
}
}
return favoritesList;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment