Ejemplo n.º 1
0
        protected async Task <Guid> ProcessTeam(string lookupId, string teamName, Guid?countryGuid)
        {
            var lookupTeamSearch = await Provider.GetLookupTeam(ImportSite, lookupId);

            if (lookupTeamSearch != null)
            {
                return(lookupTeamSearch.TeamGuid);
            }
            else
            {
                var teamGuid = Guid.NewGuid();

                Provider.Add(new Team()
                {
                    PrimaryKey = teamGuid
                });

                var teamV = TeamV.CreateNew <TeamV>(User.GetUserId());
                teamV.HeaderKey     = teamGuid;
                teamV.CountryGuid   = countryGuid;
                teamV.EffectiveFrom = Date.LowDate;
                teamV.EffectiveTo   = Date.HighDate;

                teamV.TeamNames = new List <TeamName>();
                teamV.TeamNames.Add(new TeamName()
                {
                    PrimaryKey   = Guid.NewGuid(),
                    TeamVKey     = teamV.PrimaryKey,
                    TeamNameType = TeamNameType.Primary,
                    LanguageType = LanguageType.Native,
                    Description  = teamName
                });

                Provider.Add(teamV);

                Provider.Add(new LookupTeam()
                {
                    PrimaryKey = Guid.NewGuid(),
                    ImportSite = ImportSite,
                    TeamGuid   = teamGuid,
                    LookupId   = lookupId
                });

                Provider.SaveChanges();

                return(teamGuid);
            }
        }