public async Task <IActionResult> Edit(string id, GymInputModel gymInput) { var existsGym = this.gymsService .Exists(x => x.Id == id); if (!existsGym) { return(this.NotFound()); } if (!this.ModelState.IsValid) { var gym = new GymEditViewModel() { Id = id, GymInput = gymInput, }; this.SetCountrySelectListItems(gym.GymInput); this.SetCitySelectListItems(gym.GymInput); return(this.View(gym)); } var image = await this.cloudinaryService.SaveImageAsync(gymInput.FormFile); await this.gymsService.EditAsync(id, gymInput, image); var encodedGymName = HttpUtility.HtmlEncode(gymInput.Name); this.TempData[GlobalConstants.MessageKey] = $"Successfully edited gym <strong>{encodedGymName}</strong>!"; return(this.RedirectToAction("Details", "Gyms", new { area = "Places", id })); }
public IActionResult Edit(string id) { var existsGym = this.gymsService .Exists(x => x.Id == id); if (!existsGym) { return(this.NotFound()); } var gym = new GymEditViewModel() { Id = id, GymInput = this.gymsService .GetSingle <GymInputModel>(x => x.Id == id), }; this.SetCountrySelectListItems(gym.GymInput); this.SetCitySelectListItems(gym.GymInput); return(this.View(gym)); }