コード例 #1
0
        public async Task <ActionResult <FamilyCar> > PostFamilyCar(FamilyCar familyCar)
        {
            _context.FamilyCar.Add(familyCar);
            await _context.SaveChangesAsync();

            return(familyCar);
        }
コード例 #2
0
        public async Task <ActionResult <TypeCar> > PostTypeCar(TypeCar typeCar)
        {
            _context.TypeCar.Add(typeCar);
            await _context.SaveChangesAsync();

            return(typeCar);
        }
コード例 #3
0
        public async Task <ActionResult <Tracks> > SaveTracking(Tracks tracks)
        {
            await _context.Tracks.AddAsync(tracks);

            await _context.SaveChangesAsync();

            return(tracks);
        }
コード例 #4
0
        public async Task <ActionResult <Car> > DeleteCar(long id)
        {
            var car = await _context.Car.FindAsync(id);

            _context.Car.Remove(car);
            await _context.SaveChangesAsync();

            return(car);
        }
コード例 #5
0
        public async Task <ActionResult <Car> > DeleteUserCar(long userid, long carid)
        {
            var car = await _context.Car.Where(u => u.CarId == carid && u.UserId == userid).FirstOrDefaultAsync();

            _context.Car.Remove(car);
            await _context.SaveChangesAsync();

            return(car);
        }
コード例 #6
0
        public async Task <ActionResult <User> > DeleteUser(long id)
        {
            var user = await _context.User.FindAsync(id);

            _context.User.Remove(user);
            await _context.SaveChangesAsync();

            return(user);
        }
コード例 #7
0
        public async Task <ActionResult <User> > SignUp(User user)
        {
            _context.User.Add(user);
            await _context.SaveChangesAsync();

            return(user);
        }
コード例 #8
0
        public async Task <ActionResult <Location> > DeleteUserLocation(long userid, long locId)
        {
            var location = await _context.Location.Include(u => u.LocationId == locId).FirstOrDefaultAsync(car => car.UserId == userid);

            if (location == null)
            {
                return(null);
            }

            _context.Location.Remove(location);
            await _context.SaveChangesAsync();

            return(location);
        }