Exemple #1
0
        public async Task <IActionResult> Create([Bind("TravelPackageId,CityId,NumberOfDays")] TravelPackageCity travelPackageCity)
        {
            if (ModelState.IsValid)
            {
                _db.Add(travelPackageCity);
                await _db.SaveChangesAsync();

                return(RedirectToAction(nameof(Index), new { tpId = travelPackageCity.TravelPackageId }));
            }
            ViewData["CityId"]          = new SelectList(_db.Cities, "Id", "ASCII", travelPackageCity.CityId);
            ViewData["TravelPackageId"] = new SelectList(_db.TravelPackages, "Id", "Description", travelPackageCity.TravelPackageId);
            return(View(travelPackageCity));
        }
        public async Task <IActionResult> Edit(int id, TravelPackageCity travelPackageCity)
        {
            if (id != travelPackageCity.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                await _tpcr.Update(travelPackageCity);

                return(RedirectToAction(nameof(Index), new { Id = travelPackageCity.TravelPackageId }));
            }
            return(View(travelPackageCity));
        }
        public async Task <IActionResult> Create(TravelPackageCity travelPackageCity)
        {
            await _tpcr.Add(travelPackageCity);

            return(RedirectToAction(nameof(Index), new { Id = travelPackageCity.TravelPackageId }));
        }