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")); }
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)); }
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)); }
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")); }
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));