From 1bf0c255644e18dea50018a7d425ddf7c220ac91 Mon Sep 17 00:00:00 2001 From: Syndamia Date: Thu, 13 May 2021 15:30:43 +0300 Subject: Improved redirecttoaction and removed bad checks in add feature script --- tools/add-feature-template.sh | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/tools/add-feature-template.sh b/tools/add-feature-template.sh index dd3d764..3a8695b 100755 --- a/tools/add-feature-template.sh +++ b/tools/add-feature-template.sh @@ -359,9 +359,6 @@ namespace $project_name.Web.Controllers { ${feature_name}ServiceModel serviceModel = await this._service.GetByIdAsync(Guid.Parse(id)); - if (serviceModel == null) - return RedirectToAction("Index", "Home"); - ${feature_name}WebModel webModel = this._autoMapper.Map<${feature_name}WebModel>(serviceModel); return View(webModel); } @@ -381,9 +378,9 @@ namespace $project_name.Web.Controllers bool result = await this._service.CreateAsync(serviceModel); if (result) - return RedirectToAction("Profile", "Account"); + return RedirectToAction("Index"); else - return RedirectToAction("Index", "Home"); + return RedirectToAction("Create"); } [HttpGet] @@ -391,9 +388,6 @@ namespace $project_name.Web.Controllers { ${feature_name}ServiceModel serviceModel = await this._service.GetByIdAsync(Guid.Parse(id)); - if (serviceModel == null) - return RedirectToAction("Index", "Home"); - Edit${feature_name}WebModel edit${feature_name}WebModel = this._autoMapper.Map(serviceModel); return View(edit${feature_name}WebModel); } @@ -406,9 +400,9 @@ namespace $project_name.Web.Controllers bool result = await this._service.EditAsync(serviceModel); if (result) - return RedirectToAction("Index", new { id = webModel.Id.ToString() }); + return RedirectToAction("Details", new { id = webModel.Id.ToString() }); else - return RedirectToAction("Index", "Home"); + return RedirectToAction("Edit", new { id = webModel.Id.ToString() }); } [HttpGet] @@ -423,9 +417,9 @@ namespace $project_name.Web.Controllers bool result = await this._service.DeleteAsync(Guid.Parse(id)); if (result) - return RedirectToAction("Index", "Home"); + return RedirectToAction("Index"); else - return RedirectToAction("Index", new { id = id }); + return RedirectToAction("Delete", new { id = id }); } } } -- cgit v1.2.3