コード例 #1
0
        public async Task <IActionResult> PutFriends(int id, [FromBody] Friends friends)
        {
            if (id != friends.Id)
            {
                return(BadRequest());
            }

            _context.Entry(friends).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!FriendsExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
コード例 #2
0
        public async Task <IActionResult> PutCompanyAbout(int id, [FromBody] CompanyAbout companyAbout)
        {
            //if (id != companyAbout.AvioCompID)
            //{
            //    return BadRequest();
            //}

            _context.Entry(companyAbout).State = EntityState.Modified;

            var ca = _context.CompanyAbout.FirstOrDefault(x => x.AvioCompID == companyAbout.AvioCompID);

            ca.CompanyFlights = companyAbout.CompanyFlights;
            foreach (var item in ca.CompanyFlights)
            {
                _context.Entry(item).State = item.FlightID == 0 ? EntityState.Added : EntityState.Modified;
            }

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!CompanyAboutExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
コード例 #3
0
        public async Task <IActionResult> PutFlightInfo(string id, FlightInfo flightInfo)
        {
            if (id != flightInfo.FlightID)
            {
                return(BadRequest());
            }

            _context.Entry(flightInfo).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!FlightInfoExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
コード例 #4
0
        public async Task <IActionResult> PutflightRate(int id, flightRate flightRate)
        {
            if (id != flightRate.RateIdd)
            {
                return(BadRequest());
            }

            _context.Entry(flightRate).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!flightRateExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
コード例 #5
0
        public async Task <IActionResult> PutSeat(int id, Seat seat)
        {
            if (id != seat.Id)
            {
                return(BadRequest());
            }

            _context.Entry(seat).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!SeatExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
コード例 #6
0
        public async Task <IActionResult> PutFlightInfo2(int id, FlightInfo2 flightInfo2)
        {
            //if (id != flightInfo2.FlightID)
            //{
            //    return BadRequest();
            //}
            var flightInfo = _context.FlightInfo2.FirstOrDefault(x => x.FlightID == flightInfo2.FlightID);

            flightInfo.Departing   = flightInfo2.Departing;
            flightInfo.Baggage     = flightInfo2.Baggage;
            flightInfo.ClassF      = flightInfo2.ClassF;
            flightInfo.CompanyName = flightInfo2.CompanyName;
            flightInfo.Duration    = flightInfo2.Duration;
            flightInfo.To          = flightInfo2.To;
            flightInfo.Returning   = flightInfo2.Returning;
            flightInfo.From        = flightInfo2.From;
            flightInfo.Stops       = flightInfo2.Stops;
            flightInfo.Duration    = flightInfo2.Duration;
            flightInfo.Price       = flightInfo2.Price;
            flightInfo.SeatsNumber = flightInfo2.SeatsNumber;
            flightInfo.StartTime   = flightInfo2.StartTime;
            flightInfo.EndTime     = flightInfo2.EndTime;



            _context.FlightInfo2.Update(flightInfo);
            //_context.Entry(flightInfo2).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!FlightInfo2Exists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(Ok());
        }