Ejemplo n.º 1
0
        public async Task <IActionResult> Create(PlaceSetModel placeSetModel)
        {
            if (this.ModelState.IsValid)
            {
                var place = mapper.Map <Place>(placeSetModel);
                await this.placeService.CreateAsync(place);

                return(Ok());
            }

            return(BadRequest("Model is not valid"));
        }
Ejemplo n.º 2
0
        public async Task <IActionResult> Create(PlaceSetModel placeSetModel)
        {
            if (this.ModelState.IsValid)
            {
                var place = mapper.Map <Place>(placeSetModel);
                await this.placeService.CreateAsync(place);

                return(RedirectToAction(nameof(HomeController.Index), "Home"));
            }

            return(View(placeSetModel));
        }
Ejemplo n.º 3
0
        public async Task <IActionResult> Edit(PlaceSetModel placeSetModel)
        {
            if (this.ModelState.IsValid)
            {
                var place = await this.placeService.FindAsync(placeSetModel.Id);

                place.Name        = placeSetModel.Name;
                place.Description = placeSetModel.Description;
                place.CategoryId  = placeSetModel.CategoryId;
                place.CityId      = placeSetModel.CityId;

                await this.placeService.SaveAsync(place);

                return(RedirectToAction(nameof(HomeController.Index), "Home"));
            }

            return(View(placeSetModel));
        }
Ejemplo n.º 4
0
        public async Task <IActionResult> Edit(int id, PlaceSetModel placeSetModel)
        {
            if (this.ModelState.IsValid)
            {
                var place = await this.placeService.FindAsync(id);

                place.Name        = placeSetModel.Name;
                place.Description = placeSetModel.Description;
                place.CategoryId  = placeSetModel.CategoryId;
                place.CityId      = placeSetModel.CityId;
                place.CityName    = placeSetModel.CityName;
                place.CountryId   = placeSetModel.CountryId;
                place.CountryName = placeSetModel.CountryName;

                await this.placeService.SaveAsync(place);

                return(Ok());
            }

            return(BadRequest("Model is not valid"));
        }
Ejemplo n.º 5
0
 public async Task <IActionResult> Create(PlaceSetModel input)
 => await this.Handle(
     async() => await this.placeService.Create(input),
     success : RedirectToAction(nameof(HomeController.Index), "Home"),
     failure : View(input));