public async Task <IActionResult> Edit(int id, [Bind("id,name,country,length,height,price,snowRange,shortInfo,longInfo,urlPicture,availableNumberOfTermins")] resort resort) { if (id != resort.id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(resort); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!resortExists(resort.id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(resort)); }
public async Task <IActionResult> Create([Bind("id,name,country,length,height,price,snowRange,shortInfo,longInfo,urlPicture,availableNumberOfTermins")] resort resort) { if (ModelState.IsValid) { _context.Add(resort); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(resort)); }
public void updateAvailablenumberOfTermins(int Id) { var newResort = new resort() { id = Id }; int availableNbr = (from s in _context.resort where s.id == Id select s.availableNumberOfTermins).First(); newResort.availableNumberOfTermins = --availableNbr; _context.Attach(newResort); _context.Entry(newResort).Property("availableNumberOfTermins").IsModified = true; _context.SaveChanges(); }