예제 #1
0
        public async Task <ActionResult <UserDive> > RegisterNewDive(UserDive userDive, int userId, int diveSiteId)
        {
            var diveToRegister = userDive;

            diveToRegister.User = await _context.Users.Where(u => u.UserId == userId).FirstAsync();

            diveToRegister.Dive.DiveSite = await _context.DiveSites.Where(ds => ds.DiveSiteId == diveSiteId).FirstAsync();

            _context.UserDives.Add(diveToRegister);
            await _context.SaveChangesAsync();

            return(diveToRegister);
        }
 public async Task <ActionResult <UserDive> > RegisterNewDive(UserDive userDive, int userId, int diveSiteId)
 {
     return(await _userDiveService.RegisterNewDive(userDive, userId, diveSiteId));
 }