// Add one Team
        public async Task <Team> Add(Team item)
        {
            db.Teams.Add(item);
            await db.SaveChangesAsync();

            return(item);
        }
        // Add one TeamPlayer
        public async Task <TeamPlayer> Add(TeamPlayer item)
        {
            db.TeamPlayers.Add(item);
            await db.SaveChangesAsync();

            return(item);
        }
Exemplo n.º 3
0
        // Add one Score
        public async Task <Score> Add(Score item)
        {
            db.Scores.Add(item);
            await db.SaveChangesAsync();

            return(item);
        }
        // Adding a User to the database
        public async Task <UserModel> Add(UserModel item)
        {
            if (item == null)
            {
                throw new ArgumentNullException("item");
            }

            // We convert the userModel to IdentityUser
            IdentityUser newUser = createIdentityUser(item);

            db.Users.Add(newUser);

            // We save the changes before adding the roles and the claim
            await db.SaveChangesAsync();

            // we attach the user to the role of user
            await this.userManager.AddToRoleAsync(newUser.Id, AuthenticationRoles.UserRole);

            // if the item has the administrator role at true, we add it to the user
            if (item.AdministratorRole)
            {
                await this.userManager.AddToRoleAsync(newUser.Id, AuthenticationRoles.AdministratorRole);
            }

            // Add the claim
            await this.userManager.AddClaimAsync(newUser.Id, new Claim("hasRegistered", "true"));


            return(item);
        }
        // Add one country
        public async Task <Country> Add(Country item)
        {
            db.Countries.Add(item);
            await db.SaveChangesAsync();

            return(item);
        }
        public async Task <RuleSet> Add(RuleSet item)
        {
            db.RuleSets.Add(item);
            await db.SaveChangesAsync();

            return(item);
        }
Exemplo n.º 7
0
        // Add one Season
        public async Task <Season> Add(Season item)
        {
            db.Seasons.Add(item);
            await db.SaveChangesAsync();

            return(item);
        }
Exemplo n.º 8
0
        // Add one Match
        public async Task <Match> Add(Match item)
        {
            db.Matches.Add(item);
            await db.SaveChangesAsync();

            return(item);
        }
        public async Task <League> Add(League item)
        {
            db.Leagues.Add(item);
            await db.SaveChangesAsync();

            return(item);
        }