Ejemplo n.º 1
0
        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());
        }