public void Add(string sourceName)
        {
            var reviewPage = new ReviewPage {
                SourceName = sourceName
            };

            _context.ReviewPages.Add(reviewPage);
            _context.SaveChanges();
        }
        //--- 1
        #region Implement Interface Method
        public bool  Save(ReviewPage reviewPage, List <Review> reviews, int expectedReviewCount = -1)
        {
            //--return UpsertReviewPageSet(reviewPage, reviews);
            #region SQL

            try
            {
                // Insert seed data into the database using one instance of the context
                using (DataDbContext context = new DataDbContext())
                {
                    var sourceName = !String.IsNullOrEmpty(reviewPage.SourceName) ? reviewPage.SourceName : string.Empty;
                    var callMethod = !String.IsNullOrEmpty(reviewPage.CallMethod) ? reviewPage.CallMethod : string.Empty;
                    var accountId  = !String.IsNullOrEmpty(reviewPage.AccountId) ? reviewPage.AccountId : string.Empty;
                    var locationId = !String.IsNullOrEmpty(reviewPage.LocationId) ? reviewPage.LocationId : string.Empty;
                    var externalId = !String.IsNullOrEmpty(reviewPage.ExternalId) ? reviewPage.ExternalId : string.Empty;
                    var created    = (reviewPage.Created != null) ? reviewPage.Created : DateTime.Now.ToUniversalTime();

                    var reviewPageComp = string.Concat(sourceName, callMethod);
                    reviewPageComp = string.Concat(reviewPageComp, accountId);
                    reviewPageComp = string.Concat(reviewPageComp, locationId);
                    reviewPageComp = string.Concat(reviewPageComp, externalId);


                    //--- Create a lists  of all from Review.
                    foreach (Review review in reviews)
                    {
                        //if (review.Comments != null)
                        //{
                        //foreach (Comment comment in review.Comments)
                        //{
                        //_interactions.Add(new DAC.LPM.SQLServer.Interaction()
                        //{
                        //    InteractionType = "Comment.."
                        ////ParentId = ,
                        //ParentType = "Review..",
                        //AuthorName = comment.Author.Name,
                        //AuthorProfileUrl = comment.Author.ProfileUrl,
                        //AuthorIconUrl = comment.Author.IconUrl,
                        //AuthorExternalId = "AuthorExternalId",
                        //Content = comment.Content,
                        //Created = comment.Created,
                        //    CreatedTime = comment.CreatedTime
                        //});
                        //}
                        //}
                        //else if (review.Response != null)
                        //{
                        //foreach (Response response in review.Response)
                        //{
                        //    _interactions.Add(new DAC.LPM.SQLServer.Interaction()
                        //    {
                        //        InteractionType = "Response.."
                        //        //ParentId = ,
                        //ParentType = "Review.."
                        //        AuthorName = comment.Author.Name,
                        //        AuthorProfileUrl = comment.Author.ProfileUrl,
                        //        AuthorIconUrl = comment.Author.IconUrl,
                        //        AuthorExternalId = "AuthorExternalId",
                        //        Content = comment.Content,
                        //        Created = comment.Created,
                        //        //        CreatedTime = comment.CreatedTime
                        //    });
                        //}
                        if (review.Comments != null)
                        {
                            foreach (Comment comment in review.Comments)
                            {
                                _interactions.Add(new DAC.LPM.SQLServer.Interaction()
                                {
                                    InteractionType = "Comment..",
                                    //ParentId = ,
                                    ParentType       = "Review..",
                                    AuthorName       = comment.Author.Name,
                                    AuthorProfileUrl = comment.Author.ProfileUrl,
                                    AuthorIconUrl    = comment.Author.IconUrl,
                                    //AuthorExternalId = comment.Author.ExternalId,
                                    Content = comment.Content,
                                    //ContentLength = 20,
                                    Created = comment.Created
                                              //CreatedTime = comment.CreatedTime
                                });
                            }
                        }
                        //else if (review.Response != null)
                        //{
                        //    foreach (Response response in review.Response)
                        //    {
                        //        _interactions.Add(new DAC.LPM.SQLServer.Interaction()
                        //        {
                        //            InteractionType = "Response.."
                        //            //ParentId = ,
                        //            ParentType = "Review.."
                        //            AuthorName = comment.Author.Name,
                        //            AuthorProfileUrl = comment.Author.ProfileUrl,
                        //            AuthorIconUrl = comment.Author.IconUrl,
                        //            AuthorExternalId = comment.Author.ExternalId,
                        //            Content = comment.Content,
                        //            Created = comment.Created,
                        //            //        CreatedTime = comment.CreatedTime
                        //        });
                        //    }
                        //}


                        _reviews.Add(new DAC.LPM.SQLServer.Review()
                        {
                            //ParsedId = review.ParsedId,
                            //AuthorName = review.Author.Name,
                            //AuthorProfileUrl = review.Author.ProfileUrl,
                            //AuthorIconUrl = review.Author.IconUrl,
                            //AuthorExternalId = "AuthorExternalId..",
                            //ReviewPageId_FK = reviewPageComp,
                            //Content = review.Content,
                            //Rating = review.Rating,
                            //Created = review.Created,
                            //Updated = review.Updated,
                            //LastUpdated = DateTime.Now.ToUniversalTime(),

                            ParsedId         = review.ParsedId,
                            AuthorName       = review.Author.Name,
                            AuthorProfileUrl = review.Author.ProfileUrl,
                            AuthorIconUrl    = review.Author.IconUrl,
                            //AuthorExternalId = review.Author.ExternalId,
                            ReviewPageId_FK = reviewPageComp,
                            Content         = review.Content,
                            Rating          = 1,
                            Created         = DateTime.Today.ToString(),
                            Updated         = review.Updated,
                            LastUpdated     = DateTime.Today,
                            Interactions    = _interactions
                        });
                    }

                    DAC.LPM.SQLServer.ReviewPage __reviewPage = new DAC.LPM.SQLServer.ReviewPage
                    {
                        SourceName    = sourceName,
                        CallMethod    = callMethod,
                        AccountId     = accountId,
                        LocationId    = locationId,
                        ExternalId    = externalId,
                        AverageRating = 4.1M,
                        Created       = DateTime.Today,
                        Updated       = DateTime.Today,
                        LastUpdated   = DateTime.Today,
                        Reviews       = _reviews
                    };

                    context.ReviewPages.Add(__reviewPage);
                    context.SaveChanges();
                }
            }
            catch (Exception ex)
            {
                //---logger.Error($"Exception Error: {ex.Message} Details: {ex.StackTrace} InnerException: {ex.InnerException}");
                return(false);

                throw ex;
            }

            #endregion

            return(true);
        }
        public void Insert_to_SQL_Tables_Use_EF()
        {
            var sourceName = "Google";
            var callMethod = "Api";
            var accountId  = "105294769132327896230";
            var locationId = "14880430448251263796";
            var externalId = "2366450684051732373";


            var reviewPageComp = string.Concat(sourceName, callMethod);

            reviewPageComp = string.Concat(reviewPageComp, accountId);
            reviewPageComp = string.Concat(reviewPageComp, locationId);
            reviewPageComp = string.Concat(reviewPageComp, externalId);

            try
            {
                using (DataDbContext context = new DataDbContext())
                {
                    var reviewPage = new DAC.LPM.SQLServer.ReviewPage
                    {
                        SourceName    = sourceName,
                        CallMethod    = callMethod,
                        AccountId     = accountId,
                        LocationId    = locationId,
                        ExternalId    = externalId,
                        AverageRating = 0.0M,
                        //Created = DateTime.Today,
                        Updated     = DateTime.Today,
                        LastUpdated = DateTime.Today,
                        Reviews     = new List <DAC.LPM.SQLServer.Review>
                        {
                            new DAC.LPM.SQLServer.Review
                            {
                                ParsedId         = "ParsedId",
                                AuthorName       = "AuthorName",
                                AuthorProfileUrl = "AuthorProfileUrl",
                                AuthorIconUrl    = "AuthorIconUrl",
                                AuthorExternalId = "AuthorExternalId",
                                ReviewPageId_FK  = reviewPageComp,
                                Content          = "Content for review",
                                Rating           = 1,
                                Created          = DateTime.Today.ToString(),
                                Updated          = "Review Created 2",
                                LastUpdated      = DateTime.Today,
                                Interactions     = new List <Interaction>
                                {
                                    new Interaction
                                    {
                                        InteractionType  = "Comment",
                                        ParentType       = "Review",
                                        AuthorName       = "Interaction AuthorName",
                                        AuthorProfileUrl = "AuthorProfileUrl",
                                        AuthorIconUrl    = "AuthorIconUrl",
                                        AuthorExternalId = "AuthorExternalId",
                                        Content          = "Content for Interaction",
                                        Created          = DateTime.Today.ToString(),
                                        CreatedTime      = DateTime.Today,
                                        LastUpdated      = DateTime.Today
                                    }
                                }
                            }
                        }
                    };

                    context.ReviewPages.Add(reviewPage);
                    context.SaveChanges();
                }

                /*
                 * https://msdn.microsoft.com/en-us/library/jj573936(v=vs.113).aspx
                 * Finding entities using a query
                 *
                 */


                // Use a separate instance of the context to verify correct data was saved to database
                using (DataDbContext context = new DataDbContext())
                {
                    //---Assert.AreEqual("GoogleApi105294769132327896230148804304482512637962366450684051732373", context.Reviews.Single().ReviewPageComp);
                    //Assert.AreEqual("Google", context.ReviewPages.First().SourceName);
                    Assert.AreEqual("GoogleApi105294769132327896230148804304482512637962366450684051732373", context.Reviews.First().ReviewPageId_FK);
                    //---Assert.AreEqual("Interaction AuthorName", context.Interactions.First().AuthorName);
                }
            }
            finally
            {
                //  context.Database.CloseConnection();
            }
        }
        //---
        private void Insert_Or_Update_ReviewPage_Review_Interaction(ReviewPage reviewPage, List <Review> reviews)
        {
            try
            {
                using (DataDbContext context = new DataDbContext())
                {
                    //var reviewPage_ = context.ReviewPages.Find().ReviewPageId
                }

                var sourceName = "FaceBook";
                var callMethod = "Api";
                var accountId  = "105294769132327896230";
                var locationId = "14880430448251263796";
                var externalId = "2366450684051732373";


                var reviewPageComp = string.Concat(sourceName, callMethod);
                reviewPageComp = string.Concat(reviewPageComp, accountId);
                reviewPageComp = string.Concat(reviewPageComp, locationId);
                reviewPageComp = string.Concat(reviewPageComp, externalId);

                // Insert seed data into the database using one instance of the context
                using (DataDbContext context = new DataDbContext())
                {
                    DAC.LPM.SQLServer.ReviewPage _reviewPage = new DAC.LPM.SQLServer.ReviewPage
                    {
                        SourceName    = sourceName,
                        CallMethod    = callMethod,
                        AccountId     = accountId,
                        LocationId    = locationId,
                        ExternalId    = externalId,
                        AverageRating = 0.0M,
                        //Created = DateTime.Today,
                        Updated     = DateTime.Today,
                        LastUpdated = DateTime.Today,

                        Reviews = new List <DAC.LPM.SQLServer.Review>
                        {
                            new DAC.LPM.SQLServer.Review
                            {
                                ParsedId         = "ParsedId",
                                AuthorName       = "AuthorName",
                                AuthorProfileUrl = "AuthorProfileUrl",
                                AuthorIconUrl    = "AuthorIconUrl",
                                AuthorExternalId = "AuthorExternalId",
                                ReviewPageId_FK  = reviewPageComp,
                                Content          = "Content for review",
                                //ContentLength = 20,
                                Rating      = 1,
                                Created     = DateTime.Today.ToString(),
                                Updated     = DateTime.Today.ToString(),
                                LastUpdated = DateTime.Today,

                                Interactions = new List <Interaction>
                                {
                                    new Interaction
                                    {
                                        InteractionType  = "InteractionType",
                                        ParentType       = "ParentType",
                                        AuthorName       = "AuthorName",
                                        AuthorProfileUrl = "AuthorProfileUrl",
                                        AuthorIconUrl    = "AuthorIconUrl",
                                        AuthorExternalId = "AuthorExternalId",
                                        Content          = DateTime.Today.ToString(),
                                        //ContentLength = 20,
                                        Created     = DateTime.Today.ToString(),
                                        CreatedTime = DateTime.Today,
                                        LastUpdated = DateTime.Today
                                    }
                                }
                            }
                        }
                    };

                    context.ReviewPages.Add(_reviewPage);
                    context.SaveChanges();
                }



                using (DataDbContext context = new DataDbContext())
                {
                    var service = new SQLServerServices(context);
                    var result  = service.Find("FaceBook");


                    //Assert.AreEqual("ReviewPage SourceName Test", context.ReviewPages.Find().SourceName);
                    //Assert.Equals("ReviewPage SourceName Test", context.ReviewPages.First().SourceName);
                    //Assert.AreEqual("Review AuthorName", context.Reviews.First().AuthorName);
                    //Assert.AreEqual("SQLServerTests ReviewPage SourceName Test", result.First().SourceName);

                    //--- Assert.AreEqual(2, result.Count());

                    logger.Debug($"Total # of Reviews ({result.Count()}) ");
                }
            }
            catch (Exception ex)
            {
                logger.Error(
                    $"Exception Error: {ex.Message} Details: {ex.StackTrace} InnerException: {ex.InnerException}");
                throw ex;
            }
            finally
            {
                //  context.Database.CloseConnection();
            }
        }
        public void Insert_to_SQL_Tables_Use_BusinessLogic()
        {
            try
            {
                var sourceName = "FaceBook";
                var callMethod = "Api";
                var accountId  = "105294769132327896230";
                var locationId = "14880430448251263796";
                var externalId = "2366450684051732373";


                var reviewPageComp = string.Concat(sourceName, callMethod);
                reviewPageComp = string.Concat(reviewPageComp, accountId);
                reviewPageComp = string.Concat(reviewPageComp, locationId);
                reviewPageComp = string.Concat(reviewPageComp, externalId);

                // Insert seed data into the database using one instance of the context
                using (DataDbContext context = new DataDbContext())
                {
                    var reviewPage = new DAC.LPM.SQLServer.ReviewPage
                    {
                        SourceName    = sourceName,
                        CallMethod    = callMethod,
                        AccountId     = accountId,
                        LocationId    = locationId,
                        ExternalId    = externalId,
                        AverageRating = 0.0M,
                        //Created = DateTime.Today,
                        Updated     = DateTime.Today,
                        LastUpdated = DateTime.Today,
                        Reviews     = new List <DAC.LPM.SQLServer.Review>
                        {
                            new DAC.LPM.SQLServer.Review
                            {
                                ParsedId         = "ParsedId",
                                AuthorName       = "AuthorName",
                                AuthorProfileUrl = "AuthorProfileUrl",
                                AuthorIconUrl    = "AuthorIconUrl",
                                AuthorExternalId = "AuthorExternalId",
                                ReviewPageId_FK  = reviewPageComp,
                                Content          = "Content for review",
                                //ContentLength = 20,
                                Rating       = 1,
                                Created      = DateTime.Today.ToString(),
                                Updated      = "Review Created 2",
                                LastUpdated  = DateTime.Today,
                                Interactions = new List <Interaction>
                                {
                                    new Interaction
                                    {
                                        InteractionType  = "Response",
                                        ParentType       = "Comment",
                                        AuthorName       = "AuthorName",
                                        AuthorProfileUrl = "AuthorProfileUrl",
                                        AuthorIconUrl    = "AuthorIconUrl",
                                        AuthorExternalId = "AuthorExternalId",
                                        Content          = "Content for Interaction",
                                        //ContentLength = 20,
                                        Created     = DateTime.Today.ToString(),
                                        CreatedTime = DateTime.Today,
                                        LastUpdated = DateTime.Today
                                    }
                                }
                            }
                        }
                    };

                    context.ReviewPages.Add(reviewPage);
                    context.SaveChanges();
                }

                using (DataDbContext context = new DataDbContext())
                {
                    var service = new SQLServerServices(context);
                    var result  = service.Find("FaceBook");

                    logger.Debug($"Total # of Reviews ({result.Count()}) ");

                    //---Assert.AreEqual("FaceBook", context.ReviewPages.Find().SourceName);
                    //Assert.AreEqual("FaceBook", context.ReviewPages.Find().SourceName);
                    //---Assert.AreEqual("FaceBookApi105294769132327896230148804304482512637962366450684051732373", context.Reviews.Single().ReviewPageComp);
                    Assert.AreEqual("FaceBook", result.First().SourceName);
                }
            }
            finally
            {
                //  context.Database.CloseConnection();
            }
        }