Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NEW FOLDERS #6

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions Interfaces/Items.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@


using ecommerce_api.Models;

namespace oopAPI.Interfaces
{
public interface IItemsRepositary
{
public ICollection<Items>GetItems();
}
}
10 changes: 10 additions & 0 deletions Interfaces/UserData.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
using ecommerce_api.Models;

namespace ecommerce_api.Interfaces
{
public interface IUserDataRepo
{
public ICollection<UserData> GetItems();
}

}
68 changes: 37 additions & 31 deletions Program.cs
Original file line number Diff line number Diff line change
@@ -1,31 +1,37 @@
using ecommerce_api.Data;
using Microsoft.EntityFrameworkCore;

var builder = WebApplication.CreateBuilder(args);

// Add services to the container.

builder.Services.AddControllers();
// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
builder.Services.AddEndpointsApiExplorer();
builder.Services.AddSwaggerGen();
builder.Services.AddDbContext<DataContext>(options =>
{
options.UseSqlServer(builder.Configuration.GetConnectionString("DefaultConnection"));
});
var app = builder.Build();

// Configure the HTTP request pipeline.
if (app.Environment.IsDevelopment())
{
app.UseSwagger();
app.UseSwaggerUI();
}

app.UseHttpsRedirection();

app.UseAuthorization();

app.MapControllers();

app.Run();
using ecommerce_api.Data;
using ecommerce_api.Interfaces;
using ecommerce_api.Repositaries;
using Microsoft.EntityFrameworkCore;
using oopAPI.Interfaces;
using oopAPI.Repositaries;

var builder = WebApplication.CreateBuilder(args);

// Add services to the container.

builder.Services.AddControllers();
// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
builder.Services.AddEndpointsApiExplorer();
builder.Services.AddSwaggerGen();
builder.Services.AddScoped<IItemsRepositary,ItemsRepositary>();
builder.Services.AddScoped<IUserDataRepo,UserDataRepo>();
builder.Services.AddDbContext<DataContext>(options =>
{
options.UseSqlServer(builder.Configuration.GetConnectionString("DefaultConnection"));
});
var app = builder.Build();

// Configure the HTTP request pipeline.
if (app.Environment.IsDevelopment())
{
app.UseSwagger();
app.UseSwaggerUI();
}

app.UseHttpsRedirection();

app.UseAuthorization();

app.MapControllers();

app.Run();
21 changes: 21 additions & 0 deletions Repositaries/ItemsRepositary.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@

using ecommerce_api.Data;
using ecommerce_api.Models;
using oopAPI.Interfaces;


namespace oopAPI.Repositaries
{
public class ItemsRepositary:IItemsRepositary
{
private readonly DataContext _context;
public ItemsRepositary(DataContext context) {
_context = context;
}
public ICollection<Items>GetItems() {
return _context.Items.OrderBy(p=>p.Id).ToList();
}


}
}
26 changes: 26 additions & 0 deletions Repositaries/UserDataRepo.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
using ecommerce_api.Data;
using ecommerce_api.Interfaces;
using ecommerce_api.Models;
using oopAPI.Interfaces;

namespace ecommerce_api.Repositaries
{

public class UserDataRepo : IUserDataRepo
{
private readonly DataContext _context;
public UserDataRepo(DataContext context)
{
_context = context;
}
public ICollection<UserData> GetItems()
{
return _context.Userdata.OrderBy(p => p.FirstName).ToList();
}


}
}