Beispiel #1
0
        /// <summary>
        /// Creates new user in the database.
        /// </summary>
        /// <param name="registerDto"></param>
        /// <returns></returns>
        public async Task <Guid> CreateNewUser(UserRegisterDTO userInput)
        {
            User user = ObjectFactory.CreateNewUserObject(userInput);

            DBContext.User.Add(user);
            await DBContext.SaveChangesAsync();

            return(user.ID);
        }
        public async Task <NewTweetDTO> CreateNewTweet(NewTweetDTO tweetInput)
        {
            using (glitterEntities DBContext = new glitterEntities())
            {
                Tweet newTweet = new Tweet();
                newTweet.ID        = System.Guid.NewGuid();
                newTweet.Message   = tweetInput.Message;
                newTweet.UserID    = tweetInput.UserID;
                newTweet.CreatedAt = System.DateTime.Now;
                DBContext.Tweet.Add(newTweet);
                await DBContext.SaveChangesAsync();

                tweetInput.TweetID = newTweet.ID;
            }
            return(tweetInput);
        }