public UserProfile UserByEmail(string emailAddress) { UserProfile foundProfile = null; using (CommunityDbContext db = new CommunityDbContext()) { foundProfile = db.Profiles.FirstOrDefault(x => x.EmailAddress.ToLower().Equals(emailAddress.ToLower())); } return foundProfile; }
public Topic Get(int topicId) { Topic currentTopic = null; using (CommunityDbContext db = new CommunityDbContext()) { currentTopic = db.Topics.SingleOrDefault(x => x.ID == topicId); } return currentTopic; }
public Topic Create(Post firstPost) { firstPost.CreatedBy = userServiceInstance.CurrentUser(); firstPost.Topic.CreatedBy = userServiceInstance.CurrentUser(); using (CommunityDbContext db = new CommunityDbContext()) { db.Posts.Add(firstPost); db.Topics.Add(firstPost.Topic); db.SaveChanges(); } return firstPost.Topic; }
public static UserProfile CreateNewUserProfile(string userName, string emailAddress) { var profile = new UserProfile(); profile.UserName = userName; profile.EmailAddress = emailAddress; profile.MemberSince = DateTime.Now; using (CommunityDbContext context = new CommunityDbContext()) { context.Profiles.Add(profile); context.SaveChanges(); } return profile; }