Пример #1
0
        public async Task EnsureSeedDataAsync()
        {
            var userFound = await m_userManager.FindByEmailAsync("*****@*****.**");

            if (userFound == null)
            {
                var newUser = new ChirpUser()
                {
                    UserName = "******",
                    Email    = "*****@*****.**"
                };

                var userRes = await m_userManager.CreateAsync(newUser, "qwertyui");
            }

            m_context.SaveChanges();

            if (!m_context.ChirpPosts.Any())
            {
                //Add new data
                var chirpPost = new ChirpPost()
                {
                    Message  = "First message! ChirpChirp!",
                    PostTime = DateTimeOffset.UtcNow,
                    User     = await m_userManager.FindByEmailAsync("*****@*****.**")
                };

                m_context.ChirpPosts.Add(chirpPost);

                m_context.SaveChanges();
            }
        }
Пример #2
0
 public void AddPost(ChirpPost newPost)
 {
     m_context.Add(newPost);
 }