//This method will either load a user or load an empty user. public static UserProfile LoadUserByUserName(String userName, YearnlyEntities db) { UserProfile returnedUser = new UserProfile(); UserProfile user = db.UserProfiles.Where(up => up.UserName == userName).FirstOrDefault(); if (user != null) { returnedUser = user; } return returnedUser; }
public static UserProfile LoadUserByUserId(int userId, YearnlyEntities db) { UserProfile returnedUser = new UserProfile(); returnedUser = db.UserProfiles.Where(up => up.UserId == userId).FirstOrDefault(); return returnedUser; }
public ItemsController() { db = new YearnlyEntities(); loggedInUser = UserProfile.LoadUserByUserName(WebSecurity.CurrentUserName, db); }