public async Task <IActionResult> PutFlight(string id, Flight flight)
        {
            if (id.CompareTo(flight.FlightID) != 0)
            {
                return(BadRequest());
            }

            context.Entry(flight).State = EntityState.Modified;

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

            return(NoContent());
        }
Пример #2
0
        public async Task <IActionResult> PutFlight([FromRoute] int id, [FromBody] Flight flight)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != flight.FlightId)
            {
                return(BadRequest());
            }

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

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

            return(NoContent());
        }
        public async Task <IActionResult> PutServer(string id, Server server)
        {
            if (id.CompareTo(server.ServerID) != 0)
            {
                return(BadRequest());
            }

            context.Entry(server).State = EntityState.Modified;

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

            return(NoContent());
        }
Пример #4
0
 public ActionResult Edit([Bind(Include = "ID,Name")] Flight flight)
 {
     if (ModelState.IsValid)
     {
         db.Entry(flight).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(flight));
 }
 public ActionResult Edit([Bind(Include = "ID,AirportName,CityName,Longitude,Latitude")] Airport airport)
 {
     if (ModelState.IsValid)
     {
         db.Entry(airport).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(airport));
 }