示例#1
0
        public IActionResult Edit(Tour tour)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    _db.Update(tour);
                    _db.SaveChanges();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!ToursExists(tour.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction("Index"));
            }

            ViewData["TourKindId"] = new SelectList(_db.TourKinds, "Id", "Name", tour.TourKindId);
            ViewData["ClientId"]   = new SelectList(_db.Clients, "Id", "Name", tour.ClientId);

            return(View(tour));
        }
示例#2
0
        public async Task <IActionResult> PutTour([FromBody] Tour tour)
        {
            if (tour == null)
            {
                return(BadRequest());
            }
            if (!TourExists(tour.Id))
            {
                return(NotFound());
            }

            _context.Update(tour);
            _context.SaveChanges();
            return(Ok(tour));
        }
示例#3
0
 public IActionResult Edit(TourKind tourKind)
 {
     if (ModelState.IsValid)
     {
         try
         {
             _db.Update(tourKind);
             _db.SaveChanges();
         }
         catch (DbUpdateConcurrencyException)
         {
             if (!TourKindsExists(tourKind.Id))
             {
                 return(NotFound());
             }
             else
             {
                 throw;
             }
         }
         return(RedirectToAction("Index"));
     }
     return(View(tourKind));
 }
示例#4
0
 public IActionResult Edit(Client client)
 {
     if (ModelState.IsValid)
     {
         try
         {
             _db.Update(client);
             _db.SaveChanges();
         }
         catch (DbUpdateConcurrencyException)
         {
             if (!ClientsExists(client.Id))
             {
                 return(NotFound());
             }
             else
             {
                 throw;
             }
         }
         return(RedirectToAction("Index"));
     }
     return(View(client));
 }