Exemple #1
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;
 }
Exemple #2
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;
        }