protected TweetsViewModel GetTweetViewModel(Tweet tweet) { var model = new TweetsViewModel() { Id = tweet.Id, Title = tweet.Title, Content = tweet.Content, ByUser = tweet.User.UserName }; return model; }
protected Tweet GetTweetFromViewModel(TweetsViewModel tweet, string username, IUowData db) { // Security risk... var tweetUser = db.Users.All().ToList().Find(x => x.UserName == username); Tweet result = new Tweet() { Id = tweet.Id, Content = tweet.Content, Title = tweet.Title, User = tweetUser }; return result; }