diff --git a/RepositoryPattern.API/RepositoryPattern.API.sln b/RepositoryPattern.API/RepositoryPattern.API.sln new file mode 100644 index 0000000..5f7d85b --- /dev/null +++ b/RepositoryPattern.API/RepositoryPattern.API.sln @@ -0,0 +1,22 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.12.35506.116 d17.12 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RepositoryPattern.API", "RepositoryPattern.API\RepositoryPattern.API.csproj", "{B3EA3231-ED52-431E-96B6-DAFA3173E1B4}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {B3EA3231-ED52-431E-96B6-DAFA3173E1B4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {B3EA3231-ED52-431E-96B6-DAFA3173E1B4}.Debug|Any CPU.Build.0 = Debug|Any CPU + {B3EA3231-ED52-431E-96B6-DAFA3173E1B4}.Release|Any CPU.ActiveCfg = Release|Any CPU + {B3EA3231-ED52-431E-96B6-DAFA3173E1B4}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/RepositoryPattern.API/RepositoryPattern.API/Controllers/AuthorController.cs b/RepositoryPattern.API/RepositoryPattern.API/Controllers/AuthorController.cs new file mode 100644 index 0000000..57aa026 --- /dev/null +++ b/RepositoryPattern.API/RepositoryPattern.API/Controllers/AuthorController.cs @@ -0,0 +1,82 @@ +using AutoMapper; +using Microsoft.AspNetCore.Mvc; +using RepositoryPattern.API.Domain.Contracts; +using RepositoryPattern.API.Domain.Entities; +using RepositoryPattern.API.Repositories; + +namespace RepositoryPattern.API.Controllers +{ + [ApiController] + [Route("api/")] + public class AuthorController : ControllerBase + { + private readonly IBaseRepository _authorRepository; + private readonly IMapper _mapper; + + public AuthorController(IBaseRepository authorRepository, IMapper mapper) + { + _authorRepository = authorRepository; + _mapper = mapper; + } + + + [HttpGet("authors")] + public async Task GetAuthors() + { + var authors = await _authorRepository.GetAll(a => a.Books); + var authorDtos = _mapper.Map>(authors); + return Ok(authorDtos); + } + + + [HttpGet("authors/{id}")] + public async Task GetAuthor(Guid id) + { + var author = await _authorRepository.Get(id, a => a.Books); + if (author == null) + { + return NotFound(); + } + var authorDto = _mapper.Map(author); + return Ok(authorDto); + } + + [HttpPost("authors")] + public async Task CreateAuthor([FromBody] CreateAuthor createAuthor) + { + var author = _mapper.Map(createAuthor); + var createdAuthor = await _authorRepository.Add(author); + var authorDto = _mapper.Map(createdAuthor); + return CreatedAtAction(nameof(GetAuthor), new { id = authorDto.Id }, authorDto); + } + + + [HttpPut("authors/{id}")] + public async Task UpdateAuthor(Guid id, [FromBody] UpdateAuthor updateAuthor) + { + var author = await _authorRepository.Get(id); + if (author == null) + { + return NotFound(); + } + _mapper.Map(updateAuthor, author); + var updatedAuthor = await _authorRepository.Update(author); + var authorDto = _mapper.Map(updatedAuthor); + return Ok(authorDto); + } + + + [HttpDelete("authors/{id}")] + public async Task DeleteAuthor(Guid id) + { + var author = await _authorRepository.Delete(id); + if (author == null) + { + return NotFound(); + } + var authorDto = _mapper.Map(author); + return Ok(authorDto); + } + + } +} diff --git a/RepositoryPattern.API/RepositoryPattern.API/Controllers/BookController.cs b/RepositoryPattern.API/RepositoryPattern.API/Controllers/BookController.cs new file mode 100644 index 0000000..f966bd0 --- /dev/null +++ b/RepositoryPattern.API/RepositoryPattern.API/Controllers/BookController.cs @@ -0,0 +1,87 @@ +using AutoMapper; +using Microsoft.AspNetCore.Mvc; +using RepositoryPattern.API.Domain.Contracts; +using RepositoryPattern.API.Domain.Entities; +using RepositoryPattern.API.Repositories; + +namespace RepositoryPattern.API.Controllers +{ + [ApiController] + [Route("api/")] + public class BookController : ControllerBase + { + + private readonly IBaseRepository _bookRepository; + private readonly IMapper _mapper; + + public BookController(IBaseRepository bookRepository, IMapper mapper) + { + _bookRepository = bookRepository; + _mapper = mapper; + } + + + [HttpGet("books")] + public async Task GetBooks() + { + var books = await _bookRepository.GetAll(a => a.Author); + var bookDtos = _mapper.Map>(books); + return Ok(bookDtos); + } + + + [HttpGet("books/{id}")] + public async Task GetBook(Guid id) + { + var book = await _bookRepository.Get(id, a => a.Author); + if (book == null) + { + return NotFound(); + } + var bookDto = _mapper.Map(book); + return Ok(bookDto); + } + + [HttpPost("books")] + public async Task CreateBook([FromBody] CreateBook createBook) + { + var book = _mapper.Map(createBook); + var createdBook = await _bookRepository.Add(book); + var bookDto = _mapper.Map(createdBook); + return CreatedAtAction(nameof(GetBook), new { id = bookDto.Id }, bookDto); + } + + + + [HttpPut("books/{id}")] + + public async Task UpdateBook(Guid id, [FromBody] UpdateBook updateBook) + { + var book = await _bookRepository.Get(id); + if (book == null) + { + return NotFound(); + } + _mapper.Map(updateBook, book); + var updatedBook = await _bookRepository.Update(book); + var bookDto = _mapper.Map(updatedBook); + return Ok(bookDto); + } + + + + [HttpDelete("books/{id}")] + public async Task DeleteBook(Guid id) + { + var book = await _bookRepository.Get(id); + if (book == null) + { + return NotFound(); + } + var deletedBook = await _bookRepository.Delete(id); + var bookDto = _mapper.Map(deletedBook); + return Ok(bookDto); + } + } + +} diff --git a/RepositoryPattern.API/RepositoryPattern.API/Data/AppDbContext.cs b/RepositoryPattern.API/RepositoryPattern.API/Data/AppDbContext.cs new file mode 100644 index 0000000..1db3c7c --- /dev/null +++ b/RepositoryPattern.API/RepositoryPattern.API/Data/AppDbContext.cs @@ -0,0 +1,16 @@ +using Microsoft.EntityFrameworkCore; +using RepositoryPattern.API.Domain.Entities; + +namespace RepositoryPattern.API.Data +{ + public class AppDbContext : DbContext + { + public AppDbContext(DbContextOptions options) : base(options) + { + } + + public DbSet Authors { get; set; } + public DbSet Books { get; set; } + } + +} diff --git a/RepositoryPattern.API/RepositoryPattern.API/Domain/Contracts/AuthorContract.cs b/RepositoryPattern.API/RepositoryPattern.API/Domain/Contracts/AuthorContract.cs new file mode 100644 index 0000000..c072e29 --- /dev/null +++ b/RepositoryPattern.API/RepositoryPattern.API/Domain/Contracts/AuthorContract.cs @@ -0,0 +1,38 @@ +namespace RepositoryPattern.API.Domain.Contracts +{ + public record CreateAuthor + { + public string Name { get; init; } + public string Bio { get; init; } + } + + public record UpdateAuthor + { + public string Name { get; init; } + public string Bio { get; init; } + } + + + public record DeleteAuthor + { + public Guid Id { get; init; } + + + } + + public record GetAuthor + { + public Guid Id { get; init; } + } + + + public class GetAuthorDto + { + public Guid Id { get; set; } + public string Name { get; set; } + public string Bio { get; set; } + public ICollection Books { get; set; } + } + + +} \ No newline at end of file diff --git a/RepositoryPattern.API/RepositoryPattern.API/Domain/Contracts/BookContract.cs b/RepositoryPattern.API/RepositoryPattern.API/Domain/Contracts/BookContract.cs new file mode 100644 index 0000000..21fba21 --- /dev/null +++ b/RepositoryPattern.API/RepositoryPattern.API/Domain/Contracts/BookContract.cs @@ -0,0 +1,42 @@ +namespace RepositoryPattern.API.Domain.Contracts +{ + public record CreateBook + { + public string Title { get; init; } + public double Price { get; init; } + public string Description { get; init; } + public Guid AuthorId { get; init; } + } + + + public record UpdateBook + { + public string Title { get; init; } + public double Price { get; init; } + public string Description { get; init; } + public Guid AuthorId { get; init; } + } + + + public record DeleteBook + { + public Guid Id { get; init; } + } + + + public record GetBook + { + public Guid Id { get; init; } + } + + + public class GetBookDto + { + public Guid Id { get; set; } + public string Title { get; set; } + public double Price { get; set; } + public string Description { get; set; } + public Guid AuthorId { get; set; } + } + +} diff --git a/RepositoryPattern.API/RepositoryPattern.API/Domain/Entities/Author.cs b/RepositoryPattern.API/RepositoryPattern.API/Domain/Entities/Author.cs new file mode 100644 index 0000000..0c243ea --- /dev/null +++ b/RepositoryPattern.API/RepositoryPattern.API/Domain/Entities/Author.cs @@ -0,0 +1,11 @@ +namespace RepositoryPattern.API.Domain.Entities +{ + public class Author + { + public Guid Id { get; set; } + public string Name { get; set; } + public string Bio { get; set; } + + public ICollection Books { get; set; } + } +} diff --git a/RepositoryPattern.API/RepositoryPattern.API/Domain/Entities/Book.cs b/RepositoryPattern.API/RepositoryPattern.API/Domain/Entities/Book.cs new file mode 100644 index 0000000..1b09971 --- /dev/null +++ b/RepositoryPattern.API/RepositoryPattern.API/Domain/Entities/Book.cs @@ -0,0 +1,12 @@ +namespace RepositoryPattern.API.Domain.Entities +{ + public class Book + { + public Guid Id { get; set; } + public string Title { get; set; } + public double Price { get; set; } + public string Description { get; set; } + public Guid AuthorId { get; set; } + public Author Author { get; set; } + } +} diff --git a/RepositoryPattern.API/RepositoryPattern.API/Domain/Mapping/MappingProfile.cs b/RepositoryPattern.API/RepositoryPattern.API/Domain/Mapping/MappingProfile.cs new file mode 100644 index 0000000..f6f8992 --- /dev/null +++ b/RepositoryPattern.API/RepositoryPattern.API/Domain/Mapping/MappingProfile.cs @@ -0,0 +1,29 @@ +using AutoMapper; +using RepositoryPattern.API.Domain.Contracts; +using RepositoryPattern.API.Domain.Entities; + +namespace RepositoryPattern.API.Domain.Mapping +{ + public class MappingProfile : Profile + { + public MappingProfile() + { + CreateMap() + .ForMember(dest => dest.Books, opt => opt.MapFrom(src => src.Books)); + CreateMap(); + CreateMap(); + CreateMap(); + CreateMap(); + + + // Mapping for Book + + CreateMap(); + CreateMap(); + CreateMap(); + CreateMap(); + CreateMap(); + + } + } +} diff --git a/RepositoryPattern.API/RepositoryPattern.API/Migrations/20250107023515_InitialCreate.Designer.cs b/RepositoryPattern.API/RepositoryPattern.API/Migrations/20250107023515_InitialCreate.Designer.cs new file mode 100644 index 0000000..7f2d931 --- /dev/null +++ b/RepositoryPattern.API/RepositoryPattern.API/Migrations/20250107023515_InitialCreate.Designer.cs @@ -0,0 +1,92 @@ +// +using System; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Metadata; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using RepositoryPattern.API.Data; + +#nullable disable + +namespace RepositoryPattern.API.Migrations +{ + [DbContext(typeof(AppDbContext))] + [Migration("20250107023515_InitialCreate")] + partial class InitialCreate + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "9.0.0") + .HasAnnotation("Relational:MaxIdentifierLength", 128); + + SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder); + + modelBuilder.Entity("RepositoryPattern.API.Domain.Entities.Author", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier"); + + b.Property("Bio") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Name") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.ToTable("Authors"); + }); + + modelBuilder.Entity("RepositoryPattern.API.Domain.Entities.Book", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier"); + + b.Property("AuthorId") + .HasColumnType("uniqueidentifier"); + + b.Property("Description") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Price") + .HasColumnType("float"); + + b.Property("Title") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.HasIndex("AuthorId"); + + b.ToTable("Books"); + }); + + modelBuilder.Entity("RepositoryPattern.API.Domain.Entities.Book", b => + { + b.HasOne("RepositoryPattern.API.Domain.Entities.Author", "Author") + .WithMany("Books") + .HasForeignKey("AuthorId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Author"); + }); + + modelBuilder.Entity("RepositoryPattern.API.Domain.Entities.Author", b => + { + b.Navigation("Books"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/RepositoryPattern.API/RepositoryPattern.API/Migrations/20250107023515_InitialCreate.cs b/RepositoryPattern.API/RepositoryPattern.API/Migrations/20250107023515_InitialCreate.cs new file mode 100644 index 0000000..9e7fc56 --- /dev/null +++ b/RepositoryPattern.API/RepositoryPattern.API/Migrations/20250107023515_InitialCreate.cs @@ -0,0 +1,64 @@ +using System; +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace RepositoryPattern.API.Migrations +{ + /// + public partial class InitialCreate : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.CreateTable( + name: "Authors", + columns: table => new + { + Id = table.Column(type: "uniqueidentifier", nullable: false), + Name = table.Column(type: "nvarchar(max)", nullable: false), + Bio = table.Column(type: "nvarchar(max)", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_Authors", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "Books", + columns: table => new + { + Id = table.Column(type: "uniqueidentifier", nullable: false), + Title = table.Column(type: "nvarchar(max)", nullable: false), + Price = table.Column(type: "float", nullable: false), + Description = table.Column(type: "nvarchar(max)", nullable: false), + AuthorId = table.Column(type: "uniqueidentifier", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_Books", x => x.Id); + table.ForeignKey( + name: "FK_Books_Authors_AuthorId", + column: x => x.AuthorId, + principalTable: "Authors", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateIndex( + name: "IX_Books_AuthorId", + table: "Books", + column: "AuthorId"); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropTable( + name: "Books"); + + migrationBuilder.DropTable( + name: "Authors"); + } + } +} diff --git a/RepositoryPattern.API/RepositoryPattern.API/Migrations/AppDbContextModelSnapshot.cs b/RepositoryPattern.API/RepositoryPattern.API/Migrations/AppDbContextModelSnapshot.cs new file mode 100644 index 0000000..d5f71d4 --- /dev/null +++ b/RepositoryPattern.API/RepositoryPattern.API/Migrations/AppDbContextModelSnapshot.cs @@ -0,0 +1,89 @@ +// +using System; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Metadata; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using RepositoryPattern.API.Data; + +#nullable disable + +namespace RepositoryPattern.API.Migrations +{ + [DbContext(typeof(AppDbContext))] + partial class AppDbContextModelSnapshot : ModelSnapshot + { + protected override void BuildModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "9.0.0") + .HasAnnotation("Relational:MaxIdentifierLength", 128); + + SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder); + + modelBuilder.Entity("RepositoryPattern.API.Domain.Entities.Author", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier"); + + b.Property("Bio") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Name") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.ToTable("Authors"); + }); + + modelBuilder.Entity("RepositoryPattern.API.Domain.Entities.Book", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier"); + + b.Property("AuthorId") + .HasColumnType("uniqueidentifier"); + + b.Property("Description") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Price") + .HasColumnType("float"); + + b.Property("Title") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.HasIndex("AuthorId"); + + b.ToTable("Books"); + }); + + modelBuilder.Entity("RepositoryPattern.API.Domain.Entities.Book", b => + { + b.HasOne("RepositoryPattern.API.Domain.Entities.Author", "Author") + .WithMany("Books") + .HasForeignKey("AuthorId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Author"); + }); + + modelBuilder.Entity("RepositoryPattern.API.Domain.Entities.Author", b => + { + b.Navigation("Books"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/RepositoryPattern.API/RepositoryPattern.API/Program.cs b/RepositoryPattern.API/RepositoryPattern.API/Program.cs new file mode 100644 index 0000000..b0489d7 --- /dev/null +++ b/RepositoryPattern.API/RepositoryPattern.API/Program.cs @@ -0,0 +1,50 @@ +using Microsoft.EntityFrameworkCore; +using RepositoryPattern.API.Data; +using RepositoryPattern.API.Domain.Mapping; +using RepositoryPattern.API.Repositories; +using System.Text.Json.Serialization; + +var builder = WebApplication.CreateBuilder(args); + +// Add services to the container. + +builder.Services.AddControllers() + .AddJsonOptions(options => + { + options.JsonSerializerOptions.ReferenceHandler = ReferenceHandler.IgnoreCycles; + options.JsonSerializerOptions.DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull; + }); + + +builder.Services.AddSwaggerGen(); +// Learn more about configuring OpenAPI at https://aka.ms/aspnet/openapi +builder.Services.AddOpenApi(); + +builder.Services.AddDbContext(options => +{ + options.UseSqlServer(builder.Configuration.GetConnectionString("sqlConnection")); +}); + + +builder.Services.AddScoped(typeof(IBaseRepository<>), typeof(BaseRepository<>)); +builder.Services.AddAutoMapper(typeof(MappingProfile).Assembly); + + +var app = builder.Build(); + +// Configure the HTTP request pipeline. +if (app.Environment.IsDevelopment()) +{ + app.MapOpenApi(); + + app.UseSwaggerUI(); + app.UseSwagger(); +} + +app.UseHttpsRedirection(); + +app.UseAuthorization(); + +app.MapControllers(); + +app.Run(); diff --git a/RepositoryPattern.API/RepositoryPattern.API/Properties/launchSettings.json b/RepositoryPattern.API/RepositoryPattern.API/Properties/launchSettings.json new file mode 100644 index 0000000..1d85bce --- /dev/null +++ b/RepositoryPattern.API/RepositoryPattern.API/Properties/launchSettings.json @@ -0,0 +1,23 @@ +{ + "$schema": "https://json.schemastore.org/launchsettings.json", + "profiles": { + "http": { + "commandName": "Project", + "dotnetRunMessages": true, + "launchBrowser": false, + "applicationUrl": "http://localhost:5016", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + }, + "https": { + "commandName": "Project", + "dotnetRunMessages": true, + "launchBrowser": false, + "applicationUrl": "https://localhost:7160;http://localhost:5016", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + } + } +} diff --git a/RepositoryPattern.API/RepositoryPattern.API/Repositories/BaseRepository.cs b/RepositoryPattern.API/RepositoryPattern.API/Repositories/BaseRepository.cs new file mode 100644 index 0000000..e0e7891 --- /dev/null +++ b/RepositoryPattern.API/RepositoryPattern.API/Repositories/BaseRepository.cs @@ -0,0 +1,65 @@ +using Microsoft.EntityFrameworkCore; +using RepositoryPattern.API.Data; +using System.Linq.Expressions; + +namespace RepositoryPattern.API.Repositories +{ + public class BaseRepository : IBaseRepository where T : class + { + private readonly AppDbContext _context; + + public BaseRepository(AppDbContext context) + { + _context = context; + } + + public async Task Add(T entity) + { + await _context.Set().AddAsync(entity); + await _context.SaveChangesAsync(); + return entity; + + } + + + public Task> GetAll(params Expression>[] includes) + { + IQueryable query = _context.Set(); + query = includes.Aggregate(query, (current, include) => current.Include(include)); + return query.ToListAsync(); + + } + + + + public async Task Get(Guid id, params Expression>[] includes) + { + IQueryable query = _context.Set(); + query = includes.Aggregate(query, (current, include) => current.Include(include)); + return await query.FirstOrDefaultAsync(e => EF.Property(e, "Id") == id); + } + + public async Task Update(T entity) + { + _context.Set().Update(entity); + _context.SaveChanges(); + return entity; + } + + + + public async Task Delete(Guid id) + { + + var entity = await _context.Set().FindAsync(id); + if (entity != null) + { + _context.Set().Remove(entity); + await _context.SaveChangesAsync(); + } + return entity; + } + + + } +} diff --git a/RepositoryPattern.API/RepositoryPattern.API/Repositories/IBaseRepository.cs b/RepositoryPattern.API/RepositoryPattern.API/Repositories/IBaseRepository.cs new file mode 100644 index 0000000..20f9a92 --- /dev/null +++ b/RepositoryPattern.API/RepositoryPattern.API/Repositories/IBaseRepository.cs @@ -0,0 +1,13 @@ +using System.Linq.Expressions; + +namespace RepositoryPattern.API.Repositories +{ + public interface IBaseRepository + { + Task> GetAll(params Expression>[] includes); + Task Get(Guid id, params Expression>[] includes); + Task Add(T entity); + Task Update(T entity); + Task Delete(Guid id); + } +} diff --git a/RepositoryPattern.API/RepositoryPattern.API/RepositoryPattern.API.csproj b/RepositoryPattern.API/RepositoryPattern.API/RepositoryPattern.API.csproj new file mode 100644 index 0000000..7dcacc7 --- /dev/null +++ b/RepositoryPattern.API/RepositoryPattern.API/RepositoryPattern.API.csproj @@ -0,0 +1,26 @@ + + + + net9.0 + enable + enable + + + + + + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + + + + + diff --git a/RepositoryPattern.API/RepositoryPattern.API/RepositoryPattern.API.http b/RepositoryPattern.API/RepositoryPattern.API/RepositoryPattern.API.http new file mode 100644 index 0000000..23b66dc --- /dev/null +++ b/RepositoryPattern.API/RepositoryPattern.API/RepositoryPattern.API.http @@ -0,0 +1,6 @@ +@RepositoryPattern.API_HostAddress = http://localhost:5016 + +GET {{RepositoryPattern.API_HostAddress}}/weatherforecast/ +Accept: application/json + +### diff --git a/RepositoryPattern.API/RepositoryPattern.API/appsettings.Development.json b/RepositoryPattern.API/RepositoryPattern.API/appsettings.Development.json new file mode 100644 index 0000000..ad7d4a7 --- /dev/null +++ b/RepositoryPattern.API/RepositoryPattern.API/appsettings.Development.json @@ -0,0 +1,14 @@ +{ + "Logging": { + "LogLevel": { + "Default": "Information", + "Microsoft.AspNetCore": "Warning" + } + }, + + "ConnectionStrings": { + "sqlConnection": "Server=localhost;Database=repository_parttern_db_pro;Integrated Security=true;TrustServerCertificate=true;" + }, + + "AllowedHosts": "*" +} \ No newline at end of file diff --git a/RepositoryPattern.API/RepositoryPattern.API/appsettings.json b/RepositoryPattern.API/RepositoryPattern.API/appsettings.json new file mode 100644 index 0000000..10f68b8 --- /dev/null +++ b/RepositoryPattern.API/RepositoryPattern.API/appsettings.json @@ -0,0 +1,9 @@ +{ + "Logging": { + "LogLevel": { + "Default": "Information", + "Microsoft.AspNetCore": "Warning" + } + }, + "AllowedHosts": "*" +}