public async Task <IActionResult> CreateBar(BarViewModel bar) { if (ModelState.IsValid) { try { var country = await countryServices.GetCountry(bar.CountryName); bar.CountryId = country.Id; var image = await uploadImagesServices.UploadImage(bar.Image); bar.ImageURL = image; var createdBar = await barServices.CreateBar(bar.GetDtoFromVM()); this.toastNotification.AddSuccessToastMessage(Exceptions.SuccessfullyCreated); return(RedirectToAction("ListBars", "Bar", new { Area = "" })); } catch (Exception) { this.toastNotification.AddErrorToastMessage(Exceptions.SomethingWentWrong); return(RedirectToAction("ListBars")); } } return(NoContent()); }
public async Task <IActionResult> UpdateBar(BarViewModel updatedBar, Guid id) { if (ModelState.IsValid) { try { var barDTO = updatedBar.GetDtoFromVM(); await barServices.UpdateBar(id, barDTO); this.toastNotification.AddSuccessToastMessage(Exceptions.SuccessfullyUpdated); return(RedirectToAction("ListBars", "Bar", new { Area = "" })); } catch (Exception) { this.toastNotification.AddWarningToastMessage(Exceptions.SomethingWentWrong); return(RedirectToAction("ListBars", "Bar", new { Area = "" })); } } return(View(updatedBar)); }