public UpdateReviewsById ( IEnumerable |
||
reviews | IEnumerable |
|
Результат | bool>.IDictionary |
public string TestUpdate() { SetConnectionString(); MovieEntity entity = new MovieEntity(); var rand = new Random((int)DateTimeOffset.UtcNow.Ticks); entity.RowKey = entity.MovieId = Guid.NewGuid().ToString(); entity.ReviewIds = string.Format("{0},{1}", Math.Abs(rand.Next()), Math.Abs(rand.Next())); entity.AggregateRating = Math.Abs(rand.Next(10)).ToString(); entity.Directors = string.Format("Gabbar_{0}", rand.Next()); entity.HotOrNot = (Math.Abs(rand.Next())%2) == 1 ? true : false; entity.MusicDirectors = string.Format("Rahman_{0}", Math.Abs(rand.Next())); entity.Name = string.Format("aashique {0}", rand.Next()); entity.Producers = string.Format("sippy_{0}", rand.Next()); entity.Actors = string.Format("sahruuk_{0}", rand.Next()); var reviewIds = entity.GetReviewIds(); var reviewList = new List<ReviewEntity>(); foreach (var reviewId in reviewIds) { var reviewEntity = new ReviewEntity(); reviewEntity.ReviewId = reviewEntity.RowKey = reviewId; reviewEntity.Review = string.Format("This is review number {0}", reviewId); reviewEntity.ReviewerName = string.Format("khan_{0}", rand.Next()); reviewEntity.ReviewerRating = rand.Next(10); reviewEntity.SystemRating = rand.Next(10); reviewList.Add(reviewEntity); } var tableMgr = new TableManager(); tableMgr.UpdateMovieById(entity); tableMgr.UpdateReviewsById(reviewList); return string.Format("Created movie id {0}", entity.MovieId); }
public string TestUpdate() { SetConnectionString(); MovieEntity entity = new MovieEntity(); var rand = new Random((int)DateTimeOffset.UtcNow.Ticks); #region commented code /*entity.RowKey = entity.MovieId = Guid.NewGuid().ToString(); entity.Stats = string.Format("{0},{1}", Math.Abs(rand.Next()), Math.Abs(rand.Next())); entity.Songs = Math.Abs(rand.Next(10)).ToString(); entity.Ratings = string.Format("Gabbar_{0}", rand.Next()); entity.Trailers = string.Format("Traler_{0}", rand.Next()); entity.Casts = string.Format("Rahman_{0}", Math.Abs(rand.Next())); entity.Name = string.Format("aashique {0}", rand.Next()); entity.Synopsis = string.Format("sippy_{0}", rand.Next()); entity.Posters = @"{""height"" : 300,""width"" : 200,""url"" : ""test""}"; entity.Month = "March"; entity.Year = "2014";*/ #endregion entity.RowKey = entity.MovieId = Guid.NewGuid().ToString(); entity.Stats = @"[{""budget"" : ""30,000"",""boxoffice"": ""50000""}]";; entity.Songs = @"[{""name"" : ""chaiyya chaiyya"",""url"" : ""songtest""}, {""name"" : ""chaiyya chaiyya"",""url"" : ""songtest""}]"; entity.Ratings = @"[{""system"" : 5,""critic"" : 6,""hot"" : ""no""}]"; entity.Trailers = @"[{""name"" : ""best movie"",""url"" : ""songtest""}, {""name"" : ""chaiyya chaiyya"",""url"" : ""songtest""}]"; entity.Casts = @"[{""name"" : ""ben affleck"",""charactername"" : ""mickey"",""image"" : {""height"" : 300,""width"": 200,""url"" : ""test""},""role"" : ""producer""}, {""name"" : ""jerry afflect"",""charactername"" : ""mouse"",""image"" : {""height"" : 300,""width"" : 200,""url"" : ""test""},""role"" : ""actor""}]"; entity.Pictures = @"[{""caption"" : ""test caption"",""image"" : {""height"" : 300,""width"" : 200,""url"" : ""test""}}]"; entity.Name = string.Format("aashique {0}", rand.Next()); entity.Synopsis = "this is a brilliant scary movie"; entity.Posters = @"[{""height"" : 300,""width"" : 200,""url"" : ""test""}]"; entity.Genre = "Action"; entity.Month = "March"; entity.Year = "2014"; //var reviewIds = entity.GetReviewIds(); var reviewIds = new List<string>() { Math.Abs(rand.Next()).ToString(), Math.Abs(rand.Next()).ToString() }; var reviewList = new List<ReviewEntity>(); foreach (var reviewId in reviewIds) { var reviewEntity = new ReviewEntity(); reviewEntity.ReviewId = reviewEntity.RowKey = reviewId; reviewEntity.MovieId = entity.MovieId; reviewEntity.Review = string.Format("This is review number {0}", reviewId); reviewEntity.ReviewerName = string.Format("khan_{0}", rand.Next()); reviewEntity.ReviewerRating = rand.Next(10); reviewEntity.SystemRating = rand.Next(10); reviewEntity.Hot = false; reviewEntity.OutLink = "this is a link"; reviewEntity.Affiliation= @"[{""name"" : ""Yahoo"", ""link"" : ""http://in.yahoo.com/?p=us"", ""reviewlink"" : ""http://in.movies.yahoo.com/blogs/movie-reviews/yahoo-movies-review-gunday-124034093.html"", ""logoimage"" : ""Images/Yahoo_Logo.png""},{""name"" : ""Hidustan Times"", ""link"" : ""http://www.hindustantimes.com"", ""reviewlink"" : ""http://www.hindustantimes.com/entertainment/reviews/movie-review-by-rashid-irani-dallas-buyers-club-is-a-must-watch/article1-1189520.aspx"", ""logoimage"" : ""Images/hindustan-times.jpg""}]"; reviewList.Add(reviewEntity); } var tableMgr = new TableManager(); tableMgr.UpdateMovieById(entity); tableMgr.UpdateReviewsById(reviewList); return string.Format("Created movie id {0}", entity.MovieId); }