Example #1
0
 public SrpImporter(string connectionString, ILogger logger, SrpImporterRequest request, bool isNational = false)
 {
     _isNational        = isNational;
     _dbContext         = new SRP3Entities(connectionString);
     _logger            = logger;
     _request           = request;
     _nationalCommunity = GetNationalCommunity();
     if (!isNational)
     {
         _region  = GetRegion();
         _cluster = GetCluster();
     }
 }
Example #2
0
        private NationalCommunity GetNationalCommunity()
        {
            _logger.Log("Getting National Community...");
            var nc = _dbContext.NationalCommunities.FirstOrDefault(n => n.Name == _request.NationalCommunity);

            if (nc == null)
            {
                _logger.LogEnd("Not found");
                _logger.Log("Creating National Community..." + _request.NationalCommunity);
                nc = new NationalCommunity()
                {
                    Name                 = _request.NationalCommunity,
                    CreatedTimestamp     = DateTime.Now,
                    LastUpdatedTimestamp = DateTime.Now,
                    GUID                 = Guid.NewGuid()
                };
                _dbContext.NationalCommunities.Add(nc);
                _dbContext.SaveChanges();
                _logger.LogEnd("...Done");
                return(nc);
            }
            _logger.LogEnd("Found " + _request.NationalCommunity);
            return(nc);
        }