Exemplo n.º 1
0
 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;
 }
Exemplo n.º 2
0
 public Topic Get(int topicId)
 {
     Topic currentTopic = null;
     using (CommunityDbContext db = new CommunityDbContext())
     {
         currentTopic = db.Topics.SingleOrDefault(x => x.ID == topicId);
     }
     return currentTopic;
 }
Exemplo n.º 3
0
 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;
 }
Exemplo n.º 4
0
        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;
        }