aboutsummaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorSyndamia <kamen.d.mladenov@protonmail.com>2021-05-12 16:04:48 +0300
committerSyndamia <kamen.d.mladenov@protonmail.com>2021-05-12 16:04:48 +0300
commite31d09d1ef195bbcc1f8455d58f401125a3050a9 (patch)
tree645ad8a63face3b306abc8ca8d68d1f46703ff84 /tools
parent2b1bfcd50bfc34762f8a2ed57d5099037062bd75 (diff)
downloadit-kariera-exam-template-e31d09d1ef195bbcc1f8455d58f401125a3050a9.tar
it-kariera-exam-template-e31d09d1ef195bbcc1f8455d58f401125a3050a9.tar.gz
it-kariera-exam-template-e31d09d1ef195bbcc1f8455d58f401125a3050a9.zip
Implemented interfaces for services in add feature template; Added an interfaces for UserService
Diffstat (limited to 'tools')
-rwxr-xr-xtools/add-feature-template.sh36
1 files changed, 30 insertions, 6 deletions
diff --git a/tools/add-feature-template.sh b/tools/add-feature-template.sh
index 131f2c0..ca0c8d5 100755
--- a/tools/add-feature-template.sh
+++ b/tools/add-feature-template.sh
@@ -64,9 +64,33 @@ fi
dir="../$project_name/Services"
# {{{ --------------------------->
-# Create Service
+# Create Service and Interface
+
+cat > $dir/Interfaces/I${feature_name}Service.cs<< EOF
+using System;
+using System.Threading.Tasks;
+using $project_name.Services.Models.$feature_name;
+using System.Collections.Generic;
+
+namespace $project_name.Services.Interfaces
+{
+ public interface I${feature_name}Service
+ {
+ Task<bool> CreateAsync(Create${feature_name}ServiceModel create${feature_name}ServiceModel);
+
+ Task<${feature_name}ServiceModel> GetByIdAsync(Guid id);
+
+ List<${feature_name}ServiceModel> GetAll();
+
+ Task<bool> EditAsync(Edit${feature_name}ServiceModel edit${feature_name}ServiceModel);
+
+ Task<bool> DeleteAsync(Guid id);
+ }
+}
+EOF
cat > $dir/${feature_name}Service.cs<< EOF
+using $project_name.Services.Interfaces;
using System;
using System.Threading.Tasks;
using AutoMapper;
@@ -78,7 +102,7 @@ using System.Linq;
namespace $project_name.Services
{
- public class ${feature_name}Service
+ public class ${feature_name}Service : I${feature_name}Service
{
private readonly IMapper _autoMapper;
private readonly ${project_name}Context _context;
@@ -221,7 +245,7 @@ dir="../$project_name/Web"
startup_path="$dir/Startup.cs"
service_name="${feature_name}Service"
if ! grep -q "$service_name" "$startup_path"; then
- sed -z -i "s/.*AddTransient[^\n]*\n/&\t\t\tservices.AddTransient<$service_name>();\n/" $startup_path
+ sed -z -i "s/.*AddTransient[^\n]*\n/&\t\t\tservices.AddTransient<I$service_name, $service_name>();\n/" $startup_path
fi
# }}} ---------------------------<
@@ -359,7 +383,7 @@ cat > $subdir/${feature_name}Controller.cs<< EOF
using System;
using System.Threading.Tasks;
using AutoMapper;
-using $project_name.Services;
+using $project_name.Services.Interfaces;
using $project_name.Services.Models.$feature_name;
using $project_name.Web.Models.$feature_name;
using Microsoft.AspNetCore.Mvc;
@@ -369,9 +393,9 @@ namespace $project_name.Web.Controllers
public class ${feature_name}Controller : Controller
{
private readonly IMapper _autoMapper;
- private readonly ${feature_name}Service _service;
+ private readonly I${feature_name}Service _service;
- public ${feature_name}Controller(IMapper autoMapper, ${feature_name}Service service)
+ public ${feature_name}Controller(IMapper autoMapper, I${feature_name}Service service)
{
this._autoMapper = autoMapper;
this._service = service;