コード例 #1
0
        public ActionResult FlightDeletedone(string id)
        {
            FlightsDetail flightsDetail = db.FlightsDetails.Find(id);

            db.FlightsDetails.Remove(flightsDetail);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
コード例 #2
0
 public ActionResult FlightEdit([Bind(Include = "FlightId,LaunchDate,Origin,Destination,DeptTime,ArrivalTime,NoOfSeats,Fare")] FlightsDetail flightsDetail)
 {
     if (ModelState.IsValid)
     {
         db.Entry(flightsDetail).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(flightsDetail));
 }
コード例 #3
0
        // GET: FlightsDetails/Delete/5
        public ActionResult FlightDelete(string id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            FlightsDetail flightsDetail = db.FlightsDetails.Find(id);

            if (flightsDetail == null)
            {
                return(HttpNotFound());
            }
            return(View(flightsDetail));
        }
コード例 #4
0
        public ActionResult FlightCreate([Bind(Include = "FlightId,LaunchDate,Origin,Destination,DeptTime,ArrivalTime,NoOfSeats,Fare")] FlightsDetail flightsDetail)
        {
            if (ModelState.IsValid)
            {
                if (flightsDetail.Origin == flightsDetail.Destination)
                {
                    TempData["message"] = "Origin and Destination cannot be same";
                    return(View());
                }
                else
                {
                    db.FlightsDetails.Add(flightsDetail);
                    db.SaveChanges();
                    return(RedirectToAction("FlightList"));
                }
            }

            return(View(flightsDetail));
        }