Skip to content

Commit 9061881

Browse files
committed
Services and Repositories
1 parent 47d8f05 commit 9061881

12 files changed

Lines changed: 203 additions & 34 deletions

File tree

MBDEVproAPI.API/GlobalUsings.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77
global using MBDEVproAPI.BLL.Interfaces;
88
global using MBDEVproAPI.BLL.Services;
99
global using MBDEVproAPI.DataModel;
10-
//global using MBDEVproAPI.Repository.Interfaces;
11-
//global using MBDEVproAPI.Repository.Repositories;
10+
global using MBDEVproAPI.Repository.Interfaces;
11+
global using MBDEVproAPI.Repository.Repositories;
1212
global using Microsoft.AspNetCore.Authorization;
1313
global using Microsoft.AspNetCore.Builder;
1414
global using Microsoft.AspNetCore.Hosting;

MBDEVproAPI.API/Program.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
//IServiceCollection serviceCollection = builder.Services.AddTransient<ICustomerService, CustomerService>();
1010
builder.Services.AddTransient<ICustomerService, CustomerService>();
11+
builder.Services.AddTransient<ICustomerRepository, CustomerRepository>();
1112
//builder.Services.AddScoped<ISomeService, SomeService>();
1213

1314

MBDEVproAPI.BLL/Interfaces/.gitkeep

Lines changed: 0 additions & 10 deletions
This file was deleted.
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,22 @@
11

22

3+
using Microsoft.AspNetCore.Mvc;
4+
using Microsoft.EntityFrameworkCore;
5+
36
namespace MBDEVproAPI.BLL.Interfaces
47
{
58
public interface ICustomerService : IBaseService<CustomerModel>
69
{
10+
11+
IEnumerable<CustomerModel> GetAllCustomers();
12+
13+
CustomerModel GetCustomer(int id);
14+
15+
SaveViewModel CreateCustomer(CustomerModel model);
16+
17+
SaveViewModel EditCustomer(int id, CustomerModel model);
18+
19+
SaveViewModel DeleteCustomer(int id);
20+
721
}
822
}
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,71 @@
11

2+
using MBDEVproAPI.DataModel;
3+
using Microsoft.AspNetCore.Http.HttpResults;
4+
25
namespace MBDEVproAPI.BLL.Services
36
{
47
public class CustomerService : ICustomerService
58
{
9+
10+
private readonly MBDEVproAPIDbContext _databaseContext;
11+
12+
public CustomerService(MBDEVproAPIDbContext databaseContext)
13+
{
14+
_databaseContext = databaseContext;
15+
}
16+
17+
/// <summary>
18+
/// GET ALL: Customers
19+
/// </summary>
20+
/// <returns></returns>
21+
public IEnumerable<CustomerModel> GetAllCustomers()
22+
{
23+
throw new NotImplementedException();
24+
}
25+
26+
/// <summary>
27+
/// GET: Customer
28+
/// "CustomerControllerGetCustomer": "Customer/GetCustomer"
29+
/// </summary>
30+
/// <param name="id"></param>
31+
/// <returns></returns>
32+
public CustomerModel GetCustomer(int id)
33+
{
34+
throw new NotImplementedException();
35+
}
36+
37+
/// <summary>
38+
/// CREATE: Customer
39+
/// "CustomerControllerCreateCustomer": "Customer/CreateCustomer"
40+
/// </summary>
41+
/// <param name="model"></param>
42+
/// <returns></returns>
43+
public SaveViewModel CreateCustomer(CustomerModel model)
44+
{
45+
throw new NotImplementedException();
46+
}
47+
48+
/// <summary>
49+
/// EDIT: Customer
50+
/// "CustomerControllerEditCustomer": "Customer/EditCustomer"
51+
/// </summary>
52+
/// <param name="model"></param>
53+
/// <returns></returns>
54+
public SaveViewModel EditCustomer(int id, CustomerModel model)
55+
{
56+
throw new NotImplementedException();
57+
}
58+
59+
/// <summary>
60+
/// DELETE: Customer
61+
/// "CustomerControllerDeleteCustomer": "Customer/DeleteCustomer"
62+
/// </summary>
63+
/// <param name="id"></param>
64+
/// <returns></returns>
65+
public SaveViewModel DeleteCustomer(int id)
66+
{
67+
throw new NotImplementedException();
68+
}
69+
670
}
771
}

MBDEVproAPI.Repository/GlobalUsings.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
global using System.Collections.Generic;
33
global using System.Data;
44
global using System.Linq;
5-
//global using MBDEVproAPI.DataModel.Entities;
6-
//global using MBDEVproAPI.Repository.Interfaces;
5+
global using MBDEVproAPI.DataModel.Entities;
6+
global using MBDEVproAPI.Repository.Interfaces;
77
global using Microsoft.Extensions.Configuration;
88
global using Serilog;
99
global using Serilog.Formatting.Json;

MBDEVproAPI.Repository/Interfaces/.gitkeep

Lines changed: 0 additions & 10 deletions
This file was deleted.
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+

2+
namespace MBDEVproAPI.Repository.Interfaces
3+
{
4+
public interface IBaseRepository<T>
5+
{
6+
7+
/// <summary>
8+
///
9+
/// </summary>
10+
/// <param name="obj"></param>
11+
void Add(T obj);
12+
13+
/// <summary>
14+
///
15+
/// </summary>
16+
/// <param name="obj"></param>
17+
void Remove(int id, T obj);
18+
19+
/// <summary>
20+
///
21+
/// </summary>
22+
/// <param name="id"></param>
23+
/// <returns></returns>
24+
T GetByID(int? id);
25+
26+
/// <summary>
27+
///
28+
/// </summary>
29+
/// <param name="id"></param>
30+
/// <returns></returns>
31+
IEnumerable<T> GetAll(int id);
32+
33+
/// <summary>
34+
///
35+
/// </summary>
36+
void SaveChanges();
37+
38+
}
39+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
using MBDEVproAPI.Common.Models;
2+
using System;
3+
using System.Collections.Generic;
4+
using System.Text;
5+
6+
namespace MBDEVproAPI.Repository.Interfaces
7+
{
8+
public interface ICustomerRepository : IBaseRepository<CustomerModel>
9+
{
10+
}
11+
}

MBDEVproAPI.Repository/Repositories/.gitkeep

Lines changed: 0 additions & 10 deletions
This file was deleted.

0 commit comments

Comments
 (0)