Esempio n. 1
0
    private async Task <Person> addDBPersonAsync(DbPerson dbPerson)
    {
        await context.Persons.AddAsync(dbPerson);

        await context.SaveChangesAsync();

        return(mapper.Map <Person>(dbPerson));
    }
Esempio n. 2
0
    public async Task <Donation> AddAsync(Donation donation)
    {
        var newDonation = mapper.Map <DbDonation>(donation);

        context.Donations.Add(newDonation);
        await context.SaveChangesAsync();

        return(mapper.Map <Donation>(newDonation));
    }
Esempio n. 3
0
    public async Task <Event> AddAsync(Event @event)
    {
        var newEvent = mapper.Map <DbEvent>(@event);

        context.Events.Add(newEvent);
        await context.SaveChangesAsync();

        return(mapper.Map <Event>(newEvent));
    }
    public async Task <Registration> AddAsync(Registration registration)
    {
        var dbRegistration = mapper.Map <DbRegistration>(registration);

        context.Registrations.Add(dbRegistration);
        await context.SaveChangesAsync();

        return(mapper.Map <Registration>(dbRegistration));
    }
Esempio n. 5
0
    public async Task <DtoPageData> AddAsync(DtoPageData pageData)
    {
        var dbPageData = mapper.Map <DbPageData>(pageData);

        await context.PageData.AddAsync(dbPageData);

        await context.SaveChangesAsync();

        return(mapper.Map <DtoPageData>(dbPageData));
    }
Esempio n. 6
0
    public async Task <Team> AddAsync(Team team)
    {
        var existingEvent = await EntityFrameworkQueryableExtensions.FirstOrDefaultAsync(context.Events, c => c.ID == team.EventID);

        var newTeam = team.WithEventId(existingEvent.ID);
        var dbTeam  = mapper.Map <DbTeam>(newTeam);

        await context.Teams.AddAsync(dbTeam);

        existingEvent.Teams.Add(dbTeam);

        context.Update(existingEvent);

        await context.SaveChangesAsync();

        return(mapper.Map <Team>(dbTeam));
    }