public async Task <IActionResult> Edit(int id, [Bind("Id,Title,Description,Image,Price,ShipName")] CabinsModel cabinsModel, IFormFile imageFile) { if (id != cabinsModel.Id) { return(NotFound()); } if (imageFile != null) { cabinsModel.Image = ImageHelper.AddImage(_appEnvironment, imageFile); } if (ModelState.IsValid) { try { _context.Update(cabinsModel); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!CabinsModelExists(cabinsModel.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(cabinsModel)); }
public async Task <IActionResult> Create([Bind("Id,Title,Description,Image,Price,ShipName")] CabinsModel cabinsModel, IFormFile imageFile) { if (imageFile != null) { cabinsModel.Image = ImageHelper.AddImage(_appEnvironment, imageFile); } if (ModelState.IsValid) { _context.Add(cabinsModel); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(cabinsModel)); }