예제 #1
0
        public async Task <IHttpActionResult> PutFlight(int id, [FromBody] FlightPassengerDTO fpDTO)
        {
            var fp = db.FlightsPassengers
                     .FirstOrDefault(f => (f.FlightId == fpDTO.FlightId && f.PassengerId == fpDTO.PassengerId));

            if (fp == null)
            {
                return(NotFound());
            }

            fp.IsCheckedIn = fpDTO.IsChecked;

            db.Entry(fp).State = EntityState.Modified;

            try
            {
                await db.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                throw;
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
예제 #2
0
        public async Task <bool> AddPizzeriaAsync(Pizzeria pizzeria)
        {
            try
            {
                var tracking = await _databaseContext.Pizzerias.AddAsync(pizzeria);

                var isAdded = tracking.State == EntityState.Added;
                await _databaseContext.SaveChangesAsync();

                return(isAdded);
            }
            catch (Exception)
            {
                return(false);
            }
        }