From f8c6cb1fc8f8004716218b85c357e99a4a96fc14 Mon Sep 17 00:00:00 2001 From: Vasjen Date: Wed, 23 Aug 2023 15:07:05 +0400 Subject: [PATCH 1/8] Added Swagger documentation to the project --- .vscode/settings.json | 3 +++ Startup.cs | 35 ++++++++++++++++++++++++++++++++++- TodoApiDTO.csproj | 16 ++++++++-------- 3 files changed, 45 insertions(+), 9 deletions(-) create mode 100644 .vscode/settings.json diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 00000000..df5b2381 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,3 @@ +{ + "dotnet.defaultSolution": "TodoApiDTO.sln" +} \ No newline at end of file diff --git a/Startup.cs b/Startup.cs index bbfbc83d..6780c7c7 100644 --- a/Startup.cs +++ b/Startup.cs @@ -11,6 +11,9 @@ using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Hosting; using Microsoft.Extensions.Logging; +using Microsoft.OpenApi.Any; +using Microsoft.OpenApi.Interfaces; +using Microsoft.OpenApi.Models; using TodoApi.Models; namespace TodoApi @@ -30,6 +33,32 @@ public void ConfigureServices(IServiceCollection services) services.AddDbContext(opt => opt.UseInMemoryDatabase("TodoList")); services.AddControllers(); + services.AddSwaggerGen(options => + { + options.SwaggerDoc("v1", + new OpenApiInfo + { + Title = "Swagger TodoApi Documentation", + Version = "v1", + Description = "API Documentation for the TodoApi application", + Contact = new OpenApiContact + { + Name = "Vasilii Mukhin", + Email = "vasjenm@gmail.com" + }, + Extensions = new Dictionary + { + {"x-logo", new OpenApiObject + { + {"url", new OpenApiString("~/logo.png")}, + { "altText", new OpenApiString("TodoApi logo")} + } + } + } + + }); + options.EnableAnnotations(); + }); } // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. @@ -38,6 +67,10 @@ public void Configure(IApplicationBuilder app, IWebHostEnvironment env) if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); + app.UseSwagger(); + app.UseSwaggerUI(options => + options.SwaggerEndpoint("/swagger/v1/swagger.json", + "Swagger TodoApi Documentation v1")); } app.UseHttpsRedirection(); @@ -45,7 +78,7 @@ public void Configure(IApplicationBuilder app, IWebHostEnvironment env) app.UseRouting(); app.UseAuthorization(); - + app.UseEndpoints(endpoints => { endpoints.MapControllers(); diff --git a/TodoApiDTO.csproj b/TodoApiDTO.csproj index bba6f6af..0eba139a 100644 --- a/TodoApiDTO.csproj +++ b/TodoApiDTO.csproj @@ -1,18 +1,18 @@ - netcoreapp3.1 - runtime; build; native; contentfiles; analyzers; buildtransitive all - - - + + + + + + + - - - + \ No newline at end of file From 0382065d1bbb8c83ee53400ab7caaafc7dfafca3 Mon Sep 17 00:00:00 2001 From: Vasjen Date: Wed, 23 Aug 2023 15:37:44 +0400 Subject: [PATCH 2/8] Add MSSQL to the project. --- Controllers/TodoItemsController.cs | 5 ++- Data/AppDbContext.cs | 33 ++++++++++++++++ Migrations/20230823112633_init.Designer.cs | 46 ++++++++++++++++++++++ Migrations/20230823112633_init.cs | 31 +++++++++++++++ Migrations/AppDbContextModelSnapshot.cs | 44 +++++++++++++++++++++ Models/TodoContext.cs | 14 ------- Startup.cs | 22 +++++++---- TodoApiDTO.csproj | 17 ++++---- appsettings.json | 3 ++ 9 files changed, 183 insertions(+), 32 deletions(-) create mode 100644 Data/AppDbContext.cs create mode 100644 Migrations/20230823112633_init.Designer.cs create mode 100644 Migrations/20230823112633_init.cs create mode 100644 Migrations/AppDbContextModelSnapshot.cs delete mode 100644 Models/TodoContext.cs diff --git a/Controllers/TodoItemsController.cs b/Controllers/TodoItemsController.cs index 0ef138e7..f9f85100 100644 --- a/Controllers/TodoItemsController.cs +++ b/Controllers/TodoItemsController.cs @@ -3,6 +3,7 @@ using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; +using TodoApi.Data; using TodoApi.Models; namespace TodoApi.Controllers @@ -11,9 +12,9 @@ namespace TodoApi.Controllers [ApiController] public class TodoItemsController : ControllerBase { - private readonly TodoContext _context; + private readonly AppDbContext _context; - public TodoItemsController(TodoContext context) + public TodoItemsController(AppDbContext context) { _context = context; } diff --git a/Data/AppDbContext.cs b/Data/AppDbContext.cs new file mode 100644 index 00000000..fafd7dfb --- /dev/null +++ b/Data/AppDbContext.cs @@ -0,0 +1,33 @@ +using Microsoft.Data.SqlClient; +using Microsoft.EntityFrameworkCore; +using Microsoft.Extensions.Configuration; +using TodoApi.Models; + +namespace TodoApi.Data{ + public class AppDbContext : DbContext{ + private readonly IConfiguration _config; + + public AppDbContext(DbContextOptions options, IConfiguration config) + : base(options) + { + _config = config; + } + + public DbSet TodoItems { get; set; } + + protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) + { + var conStrBuilder = new SqlConnectionStringBuilder( + _config.GetConnectionString("ConnectionToDb")); + conStrBuilder.Password = _config.GetValue("DbPassword"); + var connection = conStrBuilder.ConnectionString; + optionsBuilder.UseSqlServer(connection); + } + protected override void OnModelCreating(ModelBuilder modelBuilder) + { + + } + + + } +} \ No newline at end of file diff --git a/Migrations/20230823112633_init.Designer.cs b/Migrations/20230823112633_init.Designer.cs new file mode 100644 index 00000000..d92586cd --- /dev/null +++ b/Migrations/20230823112633_init.Designer.cs @@ -0,0 +1,46 @@ +// +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Metadata; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using TodoApi.Data; + +namespace TodoApiDTO.Migrations +{ + [DbContext(typeof(AppDbContext))] + [Migration("20230823112633_init")] + partial class init + { + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "3.1.0") + .HasAnnotation("Relational:MaxIdentifierLength", 128) + .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); + + modelBuilder.Entity("TodoApi.Models.TodoItem", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint") + .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); + + b.Property("IsComplete") + .HasColumnType("bit"); + + b.Property("Name") + .HasColumnType("nvarchar(max)"); + + b.Property("Secret") + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.ToTable("TodoItems"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/Migrations/20230823112633_init.cs b/Migrations/20230823112633_init.cs new file mode 100644 index 00000000..7be51e4c --- /dev/null +++ b/Migrations/20230823112633_init.cs @@ -0,0 +1,31 @@ +using Microsoft.EntityFrameworkCore.Migrations; + +namespace TodoApiDTO.Migrations +{ + public partial class init : Migration + { + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.CreateTable( + name: "TodoItems", + columns: table => new + { + Id = table.Column(nullable: false) + .Annotation("SqlServer:Identity", "1, 1"), + Name = table.Column(nullable: true), + IsComplete = table.Column(nullable: false), + Secret = table.Column(nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_TodoItems", x => x.Id); + }); + } + + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropTable( + name: "TodoItems"); + } + } +} diff --git a/Migrations/AppDbContextModelSnapshot.cs b/Migrations/AppDbContextModelSnapshot.cs new file mode 100644 index 00000000..39eb93cd --- /dev/null +++ b/Migrations/AppDbContextModelSnapshot.cs @@ -0,0 +1,44 @@ +// +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Metadata; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using TodoApi.Data; + +namespace TodoApiDTO.Migrations +{ + [DbContext(typeof(AppDbContext))] + partial class AppDbContextModelSnapshot : ModelSnapshot + { + protected override void BuildModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "3.1.0") + .HasAnnotation("Relational:MaxIdentifierLength", 128) + .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); + + modelBuilder.Entity("TodoApi.Models.TodoItem", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint") + .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); + + b.Property("IsComplete") + .HasColumnType("bit"); + + b.Property("Name") + .HasColumnType("nvarchar(max)"); + + b.Property("Secret") + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.ToTable("TodoItems"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/Models/TodoContext.cs b/Models/TodoContext.cs deleted file mode 100644 index 6e59e363..00000000 --- a/Models/TodoContext.cs +++ /dev/null @@ -1,14 +0,0 @@ -using Microsoft.EntityFrameworkCore; - -namespace TodoApi.Models -{ - public class TodoContext : DbContext - { - public TodoContext(DbContextOptions options) - : base(options) - { - } - - public DbSet TodoItems { get; set; } - } -} \ No newline at end of file diff --git a/Startup.cs b/Startup.cs index 6780c7c7..68badb54 100644 --- a/Startup.cs +++ b/Startup.cs @@ -1,19 +1,15 @@ -using System; using System.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Hosting; -using Microsoft.AspNetCore.HttpsPolicy; -using Microsoft.AspNetCore.Mvc; using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Internal; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Hosting; -using Microsoft.Extensions.Logging; using Microsoft.OpenApi.Any; using Microsoft.OpenApi.Interfaces; using Microsoft.OpenApi.Models; +using TodoApi.Data; using TodoApi.Models; namespace TodoApi @@ -30,8 +26,7 @@ public Startup(IConfiguration configuration) // This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { - services.AddDbContext(opt => - opt.UseInMemoryDatabase("TodoList")); + services.AddDbContext(); services.AddControllers(); services.AddSwaggerGen(options => { @@ -83,6 +78,17 @@ public void Configure(IApplicationBuilder app, IWebHostEnvironment env) { endpoints.MapControllers(); }); + using (var scope = app.ApplicationServices.CreateScope()) + { + var services = scope.ServiceProvider; + + var context = services.GetRequiredService(); + if (context.Database.GetPendingMigrations().Any()) + { + System.Console.WriteLine("Migrating database"); + context.Database.Migrate(); + } + }; } } } diff --git a/TodoApiDTO.csproj b/TodoApiDTO.csproj index 0eba139a..5e392e5b 100644 --- a/TodoApiDTO.csproj +++ b/TodoApiDTO.csproj @@ -1,18 +1,19 @@ - + netcoreapp3.1 + 29b28247-134c-4f54-ac13-07eb6fe5bd5a runtime; build; native; contentfiles; analyzers; buildtransitive all - - - - - - - + + + + + + + \ No newline at end of file diff --git a/appsettings.json b/appsettings.json index d9d9a9bf..70d2146c 100644 --- a/appsettings.json +++ b/appsettings.json @@ -6,5 +6,8 @@ "Microsoft.Hosting.Lifetime": "Information" } }, + "ConnectionStrings": { + "ConnectionToDb": "Server=localhost;Database=TodoApi;User=sa; MultipleActiveResultSets=true; MultiSubnetFailover=True; TrustServerCertificate=True; Encrypt=false" + }, "AllowedHosts": "*" } From fbbe1e8110f0d3e83c8bb4342daf2351fa556056 Mon Sep 17 00:00:00 2001 From: Vasjen Date: Wed, 23 Aug 2023 20:01:32 +0400 Subject: [PATCH 3/8] Refactor app, add Service and repository --- Controllers/TodoItemsController.cs | 73 +++++++---------------------- Data/AppDbContext.cs | 5 +- Extensions.cs | 27 +++++++++++ Models/IEntity.cs | 10 ++++ Models/TodoItem.cs | 2 +- Services/Interfaces/IRepository.cs | 16 +++++++ Services/Interfaces/ITodoService.cs | 17 +++++++ Services/ItemsRepository.cs | 60 ++++++++++++++++++++++++ Services/TodoService.cs | 45 ++++++++++++++++++ Startup.cs | 4 ++ appsettings.json | 2 +- 11 files changed, 199 insertions(+), 62 deletions(-) create mode 100644 Extensions.cs create mode 100644 Models/IEntity.cs create mode 100644 Services/Interfaces/IRepository.cs create mode 100644 Services/Interfaces/ITodoService.cs create mode 100644 Services/ItemsRepository.cs create mode 100644 Services/TodoService.cs diff --git a/Controllers/TodoItemsController.cs b/Controllers/TodoItemsController.cs index f9f85100..932ddf71 100644 --- a/Controllers/TodoItemsController.cs +++ b/Controllers/TodoItemsController.cs @@ -5,6 +5,7 @@ using System.Threading.Tasks; using TodoApi.Data; using TodoApi.Models; +using TodoApi.Services.Interfaces; namespace TodoApi.Controllers { @@ -12,32 +13,31 @@ namespace TodoApi.Controllers [ApiController] public class TodoItemsController : ControllerBase { - private readonly AppDbContext _context; + private ITodoService _todoService; - public TodoItemsController(AppDbContext context) + public TodoItemsController(ITodoService todoService) { - _context = context; + _todoService = todoService; } - + [HttpGet] public async Task>> GetTodoItems() - { - return await _context.TodoItems - .Select(x => ItemToDTO(x)) - .ToListAsync(); + { + var todoItems = await _todoService.GetTodoItems(); + return Ok(todoItems.Select(item => item.AsDto())); } [HttpGet("{id}")] public async Task> GetTodoItem(long id) { - var todoItem = await _context.TodoItems.FindAsync(id); + var todoItem = await _todoService.GetTodoItem(id); if (todoItem == null) { return NotFound(); } - return ItemToDTO(todoItem); + return Ok(todoItem.AsDto()); } [HttpPut("{id}")] @@ -48,70 +48,31 @@ public async Task UpdateTodoItem(long id, TodoItemDTO todoItemDTO return BadRequest(); } - var todoItem = await _context.TodoItems.FindAsync(id); + var todoItem = await _todoService.GetTodoItem(id); if (todoItem == null) { return NotFound(); } - - todoItem.Name = todoItemDTO.Name; - todoItem.IsComplete = todoItemDTO.IsComplete; - - try - { - await _context.SaveChangesAsync(); - } - catch (DbUpdateConcurrencyException) when (!TodoItemExists(id)) - { - return NotFound(); - } - + await _todoService.UpdateTodoItem(id, todoItemDTO); return NoContent(); } [HttpPost] public async Task> CreateTodoItem(TodoItemDTO todoItemDTO) { - var todoItem = new TodoItem - { - IsComplete = todoItemDTO.IsComplete, - Name = todoItemDTO.Name - }; - - _context.TodoItems.Add(todoItem); - await _context.SaveChangesAsync(); - - return CreatedAtAction( - nameof(GetTodoItem), - new { id = todoItem.Id }, - ItemToDTO(todoItem)); + await _todoService.CreateTodoItem(todoItemDTO); + return Ok(todoItemDTO); } [HttpDelete("{id}")] public async Task DeleteTodoItem(long id) { - var todoItem = await _context.TodoItems.FindAsync(id); - - if (todoItem == null) + if (!await _todoService.TodoItemExists(id)) { return NotFound(); } - - _context.TodoItems.Remove(todoItem); - await _context.SaveChangesAsync(); - + await _todoService.DeleteTodoItem(id); return NoContent(); - } - - private bool TodoItemExists(long id) => - _context.TodoItems.Any(e => e.Id == id); - - private static TodoItemDTO ItemToDTO(TodoItem todoItem) => - new TodoItemDTO - { - Id = todoItem.Id, - Name = todoItem.Name, - IsComplete = todoItem.IsComplete - }; + } } } diff --git a/Data/AppDbContext.cs b/Data/AppDbContext.cs index fafd7dfb..ffb9d3cf 100644 --- a/Data/AppDbContext.cs +++ b/Data/AppDbContext.cs @@ -17,10 +17,7 @@ public AppDbContext(DbContextOptions options, IConfiguration confi protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) { - var conStrBuilder = new SqlConnectionStringBuilder( - _config.GetConnectionString("ConnectionToDb")); - conStrBuilder.Password = _config.GetValue("DbPassword"); - var connection = conStrBuilder.ConnectionString; + var connection = _config.GetConnectionString("ConnectionToDb"); optionsBuilder.UseSqlServer(connection); } protected override void OnModelCreating(ModelBuilder modelBuilder) diff --git a/Extensions.cs b/Extensions.cs new file mode 100644 index 00000000..d112771a --- /dev/null +++ b/Extensions.cs @@ -0,0 +1,27 @@ +using TodoApi.Models; + +namespace TodoApi +{ + public static class Extensions + { + public static TodoItemDTO AsDto(this IEntity todoItem) + { + return new TodoItemDTO + { + Id = todoItem.Id, + Name = todoItem.Name, + IsComplete = todoItem.IsComplete + }; + } + + public static TodoItem AsEntity(this TodoItemDTO todoItemDto) + { + return new TodoItem + { + Id = todoItemDto.Id, + Name = todoItemDto.Name, + IsComplete = todoItemDto.IsComplete + }; + } + } +} \ No newline at end of file diff --git a/Models/IEntity.cs b/Models/IEntity.cs new file mode 100644 index 00000000..e94ec45c --- /dev/null +++ b/Models/IEntity.cs @@ -0,0 +1,10 @@ +namespace TodoApi.Models +{ + public interface IEntity + { + public long Id { get; set; } + public string Name { get; set; } + public bool IsComplete { get; set; } + public string Secret { get; set; } + } +} \ No newline at end of file diff --git a/Models/TodoItem.cs b/Models/TodoItem.cs index 1f6e5465..832c8c90 100644 --- a/Models/TodoItem.cs +++ b/Models/TodoItem.cs @@ -1,7 +1,7 @@ namespace TodoApi.Models { #region snippet - public class TodoItem + public class TodoItem : IEntity { public long Id { get; set; } public string Name { get; set; } diff --git a/Services/Interfaces/IRepository.cs b/Services/Interfaces/IRepository.cs new file mode 100644 index 00000000..da83caee --- /dev/null +++ b/Services/Interfaces/IRepository.cs @@ -0,0 +1,16 @@ +using System.Collections.Generic; +using System.Threading.Tasks; +using TodoApi.Models; + +namespace TodoApi.Services.Interfaces +{ + public interface IRepository where T : class, IEntity + { + Task> GetItems(); + Task GetItem(long id); + Task UpdateItem(T entity); + Task CreateItem(T entity); + Task DeleteTodoItem(long id); + Task IEntityExists(long id); + } +} \ No newline at end of file diff --git a/Services/Interfaces/ITodoService.cs b/Services/Interfaces/ITodoService.cs new file mode 100644 index 00000000..fed5ae95 --- /dev/null +++ b/Services/Interfaces/ITodoService.cs @@ -0,0 +1,17 @@ +using System.Collections.Generic; +using System.Threading.Tasks; +using TodoApi.Models; + +namespace TodoApi.Services.Interfaces +{ + public interface ITodoService + { + Task> GetTodoItems(); + Task GetTodoItem(long id); + Task UpdateTodoItem(long id, TodoItemDTO Item); + Task CreateTodoItem(TodoItemDTO Item); + Task DeleteTodoItem(long id); + Task TodoItemExists(long id); + + } +} \ No newline at end of file diff --git a/Services/ItemsRepository.cs b/Services/ItemsRepository.cs new file mode 100644 index 00000000..bcb68e32 --- /dev/null +++ b/Services/ItemsRepository.cs @@ -0,0 +1,60 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using Microsoft.EntityFrameworkCore; +using TodoApi.Data; +using TodoApi.Models; +using TodoApi.Services.Interfaces; + +namespace TodoApi.Services +{ + public class ItemsRepository : IRepository where T: class,IEntity + { + private readonly AppDbContext _context; + + public ItemsRepository(AppDbContext context) + { + _context = context; + } + + public async Task> GetItems() + => await _context.Set().ToListAsync(); + + public async Task GetItem(long id) + => await _context.Set().AsNoTracking().Where(p => p.Id == id).SingleAsync(); + + public async Task UpdateItem(T entity) + { + if (entity == null) + throw new ArgumentNullException($"{nameof(entity)} cann't be a null"); + + _context.Set().Update(entity); + await _context.SaveChangesAsync(); + } + + public async Task CreateItem(T entity) + { + if (entity == null) + throw new ArgumentNullException($"{nameof(entity)} cann't be a null"); + + await _context.Set().AddAsync(entity); + await _context.SaveChangesAsync(); + } + + public async Task DeleteTodoItem(long id) + { + var entity = await _context.Set().AsNoTracking().Where(p => p.Id == id).SingleAsync();; + if (entity == null) + throw new NullReferenceException ($"{nameof(entity)} cann't be a null"); + + _context.Set().Remove(entity); + await _context.SaveChangesAsync(); + } + + public async Task IEntityExists(long id) => + await _context.Set().AnyAsync(e => e.Id == id); + + + } +} \ No newline at end of file diff --git a/Services/TodoService.cs b/Services/TodoService.cs new file mode 100644 index 00000000..b2dbdc97 --- /dev/null +++ b/Services/TodoService.cs @@ -0,0 +1,45 @@ +using System.Collections.Generic; +using System.Threading.Tasks; +using Microsoft.EntityFrameworkCore; +using TodoApi.Models; +using TodoApi.Services.Interfaces; + +namespace TodoApi.Services +{ + public class TodoService : ITodoService + { + private readonly IRepository _repository; + + public TodoService(IRepository repository) + { + _repository = repository; + } + + public Task CreateTodoItem(TodoItemDTO Item) + { + var todoItem = Item.AsEntity(); + return _repository.CreateItem(todoItem); + } + + public async Task DeleteTodoItem(long id) + => await _repository.DeleteTodoItem(id); + + public async Task GetTodoItem(long id) + => await _repository.GetItem(id); + + public async Task> GetTodoItems() + => await _repository.GetItems(); + + public async Task UpdateTodoItem(long id, TodoItemDTO Item) + { + var todoItem = await GetTodoItem(id); + todoItem.Name = Item.Name; + todoItem.IsComplete = Item.IsComplete; + await _repository.UpdateItem(todoItem); + } + public Task TodoItemExists(long id) + => _repository.IEntityExists(id); + } + + +} diff --git a/Startup.cs b/Startup.cs index 68badb54..8453cbb0 100644 --- a/Startup.cs +++ b/Startup.cs @@ -11,6 +11,8 @@ using Microsoft.OpenApi.Models; using TodoApi.Data; using TodoApi.Models; +using TodoApi.Services; +using TodoApi.Services.Interfaces; namespace TodoApi { @@ -28,6 +30,8 @@ public void ConfigureServices(IServiceCollection services) { services.AddDbContext(); services.AddControllers(); + services.AddScoped(typeof(IRepository<>), typeof(ItemsRepository<>)); + services.AddScoped(); services.AddSwaggerGen(options => { options.SwaggerDoc("v1", diff --git a/appsettings.json b/appsettings.json index 70d2146c..9ac1b5a5 100644 --- a/appsettings.json +++ b/appsettings.json @@ -7,7 +7,7 @@ } }, "ConnectionStrings": { - "ConnectionToDb": "Server=localhost;Database=TodoApi;User=sa; MultipleActiveResultSets=true; MultiSubnetFailover=True; TrustServerCertificate=True; Encrypt=false" + "ConnectionToDb": "Server=localhost;Database=TodoApi;User=sa;Password=Pass44w0rd;MultipleActiveResultSets=true; MultiSubnetFailover=True; TrustServerCertificate=True; Encrypt=false" }, "AllowedHosts": "*" } From a8eeb449bb755810cd555410c0e1b741c559e2d2 Mon Sep 17 00:00:00 2001 From: Vasjen Date: Wed, 23 Aug 2023 20:16:27 +0400 Subject: [PATCH 4/8] Update structure of the project. --- .gitignore => src/.gitignore | 0 {.vscode => src/.vscode}/settings.json | 0 {Controllers => src/Controllers}/TodoItemsController.cs | 0 {Data => src/Data}/AppDbContext.cs | 0 Extensions.cs => src/Extensions.cs | 0 {Migrations => src/Migrations}/20230823112633_init.Designer.cs | 0 {Migrations => src/Migrations}/20230823112633_init.cs | 0 {Migrations => src/Migrations}/AppDbContextModelSnapshot.cs | 0 {Models => src/Models}/IEntity.cs | 0 {Models => src/Models}/TodoItem.cs | 0 {Models => src/Models}/TodoItemDTO.cs | 0 Program.cs => src/Program.cs | 0 {Properties => src/Properties}/launchSettings.json | 0 README.md => src/README.md | 0 {Services => src/Services}/Interfaces/IRepository.cs | 0 {Services => src/Services}/Interfaces/ITodoService.cs | 0 {Services => src/Services}/ItemsRepository.cs | 0 {Services => src/Services}/TodoService.cs | 0 Startup.cs => src/Startup.cs | 0 TodoApiDTO.csproj => src/TodoApiDTO.csproj | 0 TodoApiDTO.sln => src/TodoApiDTO.sln | 0 appsettings.Development.json => src/appsettings.Development.json | 0 appsettings.json => src/appsettings.json | 0 23 files changed, 0 insertions(+), 0 deletions(-) rename .gitignore => src/.gitignore (100%) rename {.vscode => src/.vscode}/settings.json (100%) rename {Controllers => src/Controllers}/TodoItemsController.cs (100%) rename {Data => src/Data}/AppDbContext.cs (100%) rename Extensions.cs => src/Extensions.cs (100%) rename {Migrations => src/Migrations}/20230823112633_init.Designer.cs (100%) rename {Migrations => src/Migrations}/20230823112633_init.cs (100%) rename {Migrations => src/Migrations}/AppDbContextModelSnapshot.cs (100%) rename {Models => src/Models}/IEntity.cs (100%) rename {Models => src/Models}/TodoItem.cs (100%) rename {Models => src/Models}/TodoItemDTO.cs (100%) rename Program.cs => src/Program.cs (100%) rename {Properties => src/Properties}/launchSettings.json (100%) rename README.md => src/README.md (100%) rename {Services => src/Services}/Interfaces/IRepository.cs (100%) rename {Services => src/Services}/Interfaces/ITodoService.cs (100%) rename {Services => src/Services}/ItemsRepository.cs (100%) rename {Services => src/Services}/TodoService.cs (100%) rename Startup.cs => src/Startup.cs (100%) rename TodoApiDTO.csproj => src/TodoApiDTO.csproj (100%) rename TodoApiDTO.sln => src/TodoApiDTO.sln (100%) rename appsettings.Development.json => src/appsettings.Development.json (100%) rename appsettings.json => src/appsettings.json (100%) diff --git a/.gitignore b/src/.gitignore similarity index 100% rename from .gitignore rename to src/.gitignore diff --git a/.vscode/settings.json b/src/.vscode/settings.json similarity index 100% rename from .vscode/settings.json rename to src/.vscode/settings.json diff --git a/Controllers/TodoItemsController.cs b/src/Controllers/TodoItemsController.cs similarity index 100% rename from Controllers/TodoItemsController.cs rename to src/Controllers/TodoItemsController.cs diff --git a/Data/AppDbContext.cs b/src/Data/AppDbContext.cs similarity index 100% rename from Data/AppDbContext.cs rename to src/Data/AppDbContext.cs diff --git a/Extensions.cs b/src/Extensions.cs similarity index 100% rename from Extensions.cs rename to src/Extensions.cs diff --git a/Migrations/20230823112633_init.Designer.cs b/src/Migrations/20230823112633_init.Designer.cs similarity index 100% rename from Migrations/20230823112633_init.Designer.cs rename to src/Migrations/20230823112633_init.Designer.cs diff --git a/Migrations/20230823112633_init.cs b/src/Migrations/20230823112633_init.cs similarity index 100% rename from Migrations/20230823112633_init.cs rename to src/Migrations/20230823112633_init.cs diff --git a/Migrations/AppDbContextModelSnapshot.cs b/src/Migrations/AppDbContextModelSnapshot.cs similarity index 100% rename from Migrations/AppDbContextModelSnapshot.cs rename to src/Migrations/AppDbContextModelSnapshot.cs diff --git a/Models/IEntity.cs b/src/Models/IEntity.cs similarity index 100% rename from Models/IEntity.cs rename to src/Models/IEntity.cs diff --git a/Models/TodoItem.cs b/src/Models/TodoItem.cs similarity index 100% rename from Models/TodoItem.cs rename to src/Models/TodoItem.cs diff --git a/Models/TodoItemDTO.cs b/src/Models/TodoItemDTO.cs similarity index 100% rename from Models/TodoItemDTO.cs rename to src/Models/TodoItemDTO.cs diff --git a/Program.cs b/src/Program.cs similarity index 100% rename from Program.cs rename to src/Program.cs diff --git a/Properties/launchSettings.json b/src/Properties/launchSettings.json similarity index 100% rename from Properties/launchSettings.json rename to src/Properties/launchSettings.json diff --git a/README.md b/src/README.md similarity index 100% rename from README.md rename to src/README.md diff --git a/Services/Interfaces/IRepository.cs b/src/Services/Interfaces/IRepository.cs similarity index 100% rename from Services/Interfaces/IRepository.cs rename to src/Services/Interfaces/IRepository.cs diff --git a/Services/Interfaces/ITodoService.cs b/src/Services/Interfaces/ITodoService.cs similarity index 100% rename from Services/Interfaces/ITodoService.cs rename to src/Services/Interfaces/ITodoService.cs diff --git a/Services/ItemsRepository.cs b/src/Services/ItemsRepository.cs similarity index 100% rename from Services/ItemsRepository.cs rename to src/Services/ItemsRepository.cs diff --git a/Services/TodoService.cs b/src/Services/TodoService.cs similarity index 100% rename from Services/TodoService.cs rename to src/Services/TodoService.cs diff --git a/Startup.cs b/src/Startup.cs similarity index 100% rename from Startup.cs rename to src/Startup.cs diff --git a/TodoApiDTO.csproj b/src/TodoApiDTO.csproj similarity index 100% rename from TodoApiDTO.csproj rename to src/TodoApiDTO.csproj diff --git a/TodoApiDTO.sln b/src/TodoApiDTO.sln similarity index 100% rename from TodoApiDTO.sln rename to src/TodoApiDTO.sln diff --git a/appsettings.Development.json b/src/appsettings.Development.json similarity index 100% rename from appsettings.Development.json rename to src/appsettings.Development.json diff --git a/appsettings.json b/src/appsettings.json similarity index 100% rename from appsettings.json rename to src/appsettings.json From 50261ad37ac9a03f10c9ceb01832f269660c2a1f Mon Sep 17 00:00:00 2001 From: Vasjen Date: Wed, 23 Aug 2023 20:41:10 +0400 Subject: [PATCH 5/8] Add dockerfile --- dockerfile | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 dockerfile diff --git a/dockerfile b/dockerfile new file mode 100644 index 00000000..d4e36001 --- /dev/null +++ b/dockerfile @@ -0,0 +1,17 @@ + +FROM mcr.microsoft.com/dotnet/sdk:3.1 AS build +WORKDIR /app + +# copy csproj and restore as distinct layers +COPY ./src/*.csproj ./ +RUN dotnet restore + +# copy everything else and build app +COPY ./src/ ./ +RUN dotnet publish -c release -o /app + +# final stage/image +FROM mcr.microsoft.com/dotnet/aspnet:3.1 +WORKDIR /app +COPY --from=build /app ./ +ENTRYPOINT ["dotnet", "TodoApiDTO.dll"] \ No newline at end of file From d15bddac9f86fc46fc709cfc69698ef073b88744 Mon Sep 17 00:00:00 2001 From: Vasjen Date: Wed, 23 Aug 2023 22:57:25 +0400 Subject: [PATCH 6/8] Add deployments, update appsetings.json --- deployments/docker-compose.yaml | 33 +++++++++++++++++++++++++++++++++ src/appsettings.json | 2 +- 2 files changed, 34 insertions(+), 1 deletion(-) create mode 100644 deployments/docker-compose.yaml diff --git a/deployments/docker-compose.yaml b/deployments/docker-compose.yaml new file mode 100644 index 00000000..68c91d43 --- /dev/null +++ b/deployments/docker-compose.yaml @@ -0,0 +1,33 @@ +version: '3.7' +services: + api: + build: + context: ../ + dockerfile: dockerfile + ports: + - 9000:80 + depends_on: + - db + networks: + - mynetwork + + db: + image: mcr.microsoft.com/mssql/server:2019-latest + ports: + - 1433:1433 + environment: + - ACCEPT_EULA=Y + - MSSQL_SA_PASSWORD=Pass44w0rd + - MSSQL_TCP_ENABLED=1 + - MSSQL_TCP_PORT=1433 + - MSSQLNP_ENABLED=1 + volumes: + - dbdata:/var/opt/mssql + networks: + - mynetwork + +networks: + mynetwork: + +volumes: + dbdata: diff --git a/src/appsettings.json b/src/appsettings.json index 9ac1b5a5..68604cc0 100644 --- a/src/appsettings.json +++ b/src/appsettings.json @@ -7,7 +7,7 @@ } }, "ConnectionStrings": { - "ConnectionToDb": "Server=localhost;Database=TodoApi;User=sa;Password=Pass44w0rd;MultipleActiveResultSets=true; MultiSubnetFailover=True; TrustServerCertificate=True; Encrypt=false" + "ConnectionToDb": "Server=db;Database=TodoApi;User=sa;Password=Pass44w0rd;MultipleActiveResultSets=true; MultiSubnetFailover=True; TrustServerCertificate=True; Encrypt=false" }, "AllowedHosts": "*" } From 326c27fefe08c8c21cdfa0044a761328c2be60c5 Mon Sep 17 00:00:00 2001 From: Vasjen Date: Fri, 25 Aug 2023 22:22:47 +0400 Subject: [PATCH 7/8] Add serilog, fix pathes and update docker --- .../.idea/.gitignore | 13 +++++++++ .../.idea/indexLayout.xml | 8 +++++ .../.idea.VelvetechTestTask.dir/.idea/vcs.xml | 6 ++++ TodoApiDTO.sln | 29 +++++++++++++++++++ src/{ => TodoApi}/.gitignore | 0 src/{ => TodoApi}/.vscode/settings.json | 0 .../Controllers/TodoItemsController.cs | 0 src/{ => TodoApi}/Data/AppDbContext.cs | 0 src/{ => TodoApi}/Extensions.cs | 0 .../Infrastructure/ErrorHandlingMiddleware.cs | 7 +++++ .../20230823112633_init.Designer.cs | 0 .../Migrations/20230823112633_init.cs | 0 .../Migrations/AppDbContextModelSnapshot.cs | 0 src/{ => TodoApi}/Models/IEntity.cs | 0 src/{ => TodoApi}/Models/TodoItem.cs | 0 src/{ => TodoApi}/Models/TodoItemDTO.cs | 0 src/{ => TodoApi}/Program.cs | 0 .../Properties/launchSettings.json | 0 src/{ => TodoApi}/README.md | 0 .../Services/Interfaces/IRepository.cs | 0 .../Services/Interfaces/ITodoService.cs | 0 src/{ => TodoApi}/Services/ItemsRepository.cs | 0 src/{ => TodoApi}/Services/TodoService.cs | 0 src/{ => TodoApi}/Startup.cs | 0 src/{ => TodoApi}/TodoApiDTO.csproj | 12 ++++++++ .../appsettings.Development.json | 0 src/{ => TodoApi}/appsettings.json | 0 src/TodoApiDTO.sln | 4 +++ dockerfile => src/dockerfile | 4 +-- .../.idea/indexLayout.xml | 8 +++++ .../.idea/projectSettingsUpdater.xml | 6 ++++ .../.idea.TodoApi.Tests.dir/.idea/vcs.xml | 6 ++++ tests/TodoApi.Tests/TodoApi.Tests.csproj | 24 +++++++++++++++ tests/TodoApi.Tests/TodoApiTests.cs | 9 ++++++ tests/TodoApi.Tests/Usings.cs | 1 + 35 files changed, 135 insertions(+), 2 deletions(-) create mode 100644 .idea/.idea.VelvetechTestTask.dir/.idea/.gitignore create mode 100644 .idea/.idea.VelvetechTestTask.dir/.idea/indexLayout.xml create mode 100644 .idea/.idea.VelvetechTestTask.dir/.idea/vcs.xml create mode 100644 TodoApiDTO.sln rename src/{ => TodoApi}/.gitignore (100%) rename src/{ => TodoApi}/.vscode/settings.json (100%) rename src/{ => TodoApi}/Controllers/TodoItemsController.cs (100%) rename src/{ => TodoApi}/Data/AppDbContext.cs (100%) rename src/{ => TodoApi}/Extensions.cs (100%) create mode 100644 src/TodoApi/Infrastructure/ErrorHandlingMiddleware.cs rename src/{ => TodoApi}/Migrations/20230823112633_init.Designer.cs (100%) rename src/{ => TodoApi}/Migrations/20230823112633_init.cs (100%) rename src/{ => TodoApi}/Migrations/AppDbContextModelSnapshot.cs (100%) rename src/{ => TodoApi}/Models/IEntity.cs (100%) rename src/{ => TodoApi}/Models/TodoItem.cs (100%) rename src/{ => TodoApi}/Models/TodoItemDTO.cs (100%) rename src/{ => TodoApi}/Program.cs (100%) rename src/{ => TodoApi}/Properties/launchSettings.json (100%) rename src/{ => TodoApi}/README.md (100%) rename src/{ => TodoApi}/Services/Interfaces/IRepository.cs (100%) rename src/{ => TodoApi}/Services/Interfaces/ITodoService.cs (100%) rename src/{ => TodoApi}/Services/ItemsRepository.cs (100%) rename src/{ => TodoApi}/Services/TodoService.cs (100%) rename src/{ => TodoApi}/Startup.cs (100%) rename src/{ => TodoApi}/TodoApiDTO.csproj (63%) rename src/{ => TodoApi}/appsettings.Development.json (100%) rename src/{ => TodoApi}/appsettings.json (100%) rename dockerfile => src/dockerfile (86%) create mode 100644 tests/TodoApi.Tests/.idea/.idea.TodoApi.Tests.dir/.idea/indexLayout.xml create mode 100644 tests/TodoApi.Tests/.idea/.idea.TodoApi.Tests.dir/.idea/projectSettingsUpdater.xml create mode 100644 tests/TodoApi.Tests/.idea/.idea.TodoApi.Tests.dir/.idea/vcs.xml create mode 100644 tests/TodoApi.Tests/TodoApi.Tests.csproj create mode 100644 tests/TodoApi.Tests/TodoApiTests.cs create mode 100644 tests/TodoApi.Tests/Usings.cs diff --git a/.idea/.idea.VelvetechTestTask.dir/.idea/.gitignore b/.idea/.idea.VelvetechTestTask.dir/.idea/.gitignore new file mode 100644 index 00000000..72ebe883 --- /dev/null +++ b/.idea/.idea.VelvetechTestTask.dir/.idea/.gitignore @@ -0,0 +1,13 @@ +# Default ignored files +/shelf/ +/workspace.xml +# Rider ignored files +/.idea.VelvetechTestTask.iml +/contentModel.xml +/modules.xml +/projectSettingsUpdater.xml +# Editor-based HTTP Client requests +/httpRequests/ +# Datasource local storage ignored files +/dataSources/ +/dataSources.local.xml diff --git a/.idea/.idea.VelvetechTestTask.dir/.idea/indexLayout.xml b/.idea/.idea.VelvetechTestTask.dir/.idea/indexLayout.xml new file mode 100644 index 00000000..7b08163c --- /dev/null +++ b/.idea/.idea.VelvetechTestTask.dir/.idea/indexLayout.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/.idea.VelvetechTestTask.dir/.idea/vcs.xml b/.idea/.idea.VelvetechTestTask.dir/.idea/vcs.xml new file mode 100644 index 00000000..94a25f7f --- /dev/null +++ b/.idea/.idea.VelvetechTestTask.dir/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/TodoApiDTO.sln b/TodoApiDTO.sln new file mode 100644 index 00000000..d42e8af0 --- /dev/null +++ b/TodoApiDTO.sln @@ -0,0 +1,29 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 16 +VisualStudioVersion = 16.0.30002.166 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TodoApiDTO", "TodoApiDTO.csproj", "{623124F9-F5BA-42DD-BC26-A1720774229C}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {623124F9-F5BA-42DD-BC26-A1720774229C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {623124F9-F5BA-42DD-BC26-A1720774229C}.Debug|Any CPU.Build.0 = Debug|Any CPU + {623124F9-F5BA-42DD-BC26-A1720774229C}.Release|Any CPU.ActiveCfg = Release|Any CPU + {623124F9-F5BA-42DD-BC26-A1720774229C}.Release|Any CPU.Build.0 = Release|Any CPU + {0FAF1E6A-594A-4FDA-9F8D-B32AD299F808}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {0FAF1E6A-594A-4FDA-9F8D-B32AD299F808}.Debug|Any CPU.Build.0 = Debug|Any CPU + {0FAF1E6A-594A-4FDA-9F8D-B32AD299F808}.Release|Any CPU.ActiveCfg = Release|Any CPU + {0FAF1E6A-594A-4FDA-9F8D-B32AD299F808}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {60984BC9-01D1-4B40-9733-E459B1231F96} + EndGlobalSection +EndGlobal diff --git a/src/.gitignore b/src/TodoApi/.gitignore similarity index 100% rename from src/.gitignore rename to src/TodoApi/.gitignore diff --git a/src/.vscode/settings.json b/src/TodoApi/.vscode/settings.json similarity index 100% rename from src/.vscode/settings.json rename to src/TodoApi/.vscode/settings.json diff --git a/src/Controllers/TodoItemsController.cs b/src/TodoApi/Controllers/TodoItemsController.cs similarity index 100% rename from src/Controllers/TodoItemsController.cs rename to src/TodoApi/Controllers/TodoItemsController.cs diff --git a/src/Data/AppDbContext.cs b/src/TodoApi/Data/AppDbContext.cs similarity index 100% rename from src/Data/AppDbContext.cs rename to src/TodoApi/Data/AppDbContext.cs diff --git a/src/Extensions.cs b/src/TodoApi/Extensions.cs similarity index 100% rename from src/Extensions.cs rename to src/TodoApi/Extensions.cs diff --git a/src/TodoApi/Infrastructure/ErrorHandlingMiddleware.cs b/src/TodoApi/Infrastructure/ErrorHandlingMiddleware.cs new file mode 100644 index 00000000..1c48af52 --- /dev/null +++ b/src/TodoApi/Infrastructure/ErrorHandlingMiddleware.cs @@ -0,0 +1,7 @@ +namespace TodoApi.Infrastructure +{ + public class ErrorHandlingMiddleware + { + + } +} \ No newline at end of file diff --git a/src/Migrations/20230823112633_init.Designer.cs b/src/TodoApi/Migrations/20230823112633_init.Designer.cs similarity index 100% rename from src/Migrations/20230823112633_init.Designer.cs rename to src/TodoApi/Migrations/20230823112633_init.Designer.cs diff --git a/src/Migrations/20230823112633_init.cs b/src/TodoApi/Migrations/20230823112633_init.cs similarity index 100% rename from src/Migrations/20230823112633_init.cs rename to src/TodoApi/Migrations/20230823112633_init.cs diff --git a/src/Migrations/AppDbContextModelSnapshot.cs b/src/TodoApi/Migrations/AppDbContextModelSnapshot.cs similarity index 100% rename from src/Migrations/AppDbContextModelSnapshot.cs rename to src/TodoApi/Migrations/AppDbContextModelSnapshot.cs diff --git a/src/Models/IEntity.cs b/src/TodoApi/Models/IEntity.cs similarity index 100% rename from src/Models/IEntity.cs rename to src/TodoApi/Models/IEntity.cs diff --git a/src/Models/TodoItem.cs b/src/TodoApi/Models/TodoItem.cs similarity index 100% rename from src/Models/TodoItem.cs rename to src/TodoApi/Models/TodoItem.cs diff --git a/src/Models/TodoItemDTO.cs b/src/TodoApi/Models/TodoItemDTO.cs similarity index 100% rename from src/Models/TodoItemDTO.cs rename to src/TodoApi/Models/TodoItemDTO.cs diff --git a/src/Program.cs b/src/TodoApi/Program.cs similarity index 100% rename from src/Program.cs rename to src/TodoApi/Program.cs diff --git a/src/Properties/launchSettings.json b/src/TodoApi/Properties/launchSettings.json similarity index 100% rename from src/Properties/launchSettings.json rename to src/TodoApi/Properties/launchSettings.json diff --git a/src/README.md b/src/TodoApi/README.md similarity index 100% rename from src/README.md rename to src/TodoApi/README.md diff --git a/src/Services/Interfaces/IRepository.cs b/src/TodoApi/Services/Interfaces/IRepository.cs similarity index 100% rename from src/Services/Interfaces/IRepository.cs rename to src/TodoApi/Services/Interfaces/IRepository.cs diff --git a/src/Services/Interfaces/ITodoService.cs b/src/TodoApi/Services/Interfaces/ITodoService.cs similarity index 100% rename from src/Services/Interfaces/ITodoService.cs rename to src/TodoApi/Services/Interfaces/ITodoService.cs diff --git a/src/Services/ItemsRepository.cs b/src/TodoApi/Services/ItemsRepository.cs similarity index 100% rename from src/Services/ItemsRepository.cs rename to src/TodoApi/Services/ItemsRepository.cs diff --git a/src/Services/TodoService.cs b/src/TodoApi/Services/TodoService.cs similarity index 100% rename from src/Services/TodoService.cs rename to src/TodoApi/Services/TodoService.cs diff --git a/src/Startup.cs b/src/TodoApi/Startup.cs similarity index 100% rename from src/Startup.cs rename to src/TodoApi/Startup.cs diff --git a/src/TodoApiDTO.csproj b/src/TodoApi/TodoApiDTO.csproj similarity index 63% rename from src/TodoApiDTO.csproj rename to src/TodoApi/TodoApiDTO.csproj index 5e392e5b..15507d00 100644 --- a/src/TodoApiDTO.csproj +++ b/src/TodoApi/TodoApiDTO.csproj @@ -16,4 +16,16 @@ + + + + + runtime; build; native; contentfiles; analyzers; buildtransitive + all + + + runtime; build; native; contentfiles; analyzers; buildtransitive + all + + \ No newline at end of file diff --git a/src/appsettings.Development.json b/src/TodoApi/appsettings.Development.json similarity index 100% rename from src/appsettings.Development.json rename to src/TodoApi/appsettings.Development.json diff --git a/src/appsettings.json b/src/TodoApi/appsettings.json similarity index 100% rename from src/appsettings.json rename to src/TodoApi/appsettings.json diff --git a/src/TodoApiDTO.sln b/src/TodoApiDTO.sln index e49c182b..d42e8af0 100644 --- a/src/TodoApiDTO.sln +++ b/src/TodoApiDTO.sln @@ -15,6 +15,10 @@ Global {623124F9-F5BA-42DD-BC26-A1720774229C}.Debug|Any CPU.Build.0 = Debug|Any CPU {623124F9-F5BA-42DD-BC26-A1720774229C}.Release|Any CPU.ActiveCfg = Release|Any CPU {623124F9-F5BA-42DD-BC26-A1720774229C}.Release|Any CPU.Build.0 = Release|Any CPU + {0FAF1E6A-594A-4FDA-9F8D-B32AD299F808}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {0FAF1E6A-594A-4FDA-9F8D-B32AD299F808}.Debug|Any CPU.Build.0 = Debug|Any CPU + {0FAF1E6A-594A-4FDA-9F8D-B32AD299F808}.Release|Any CPU.ActiveCfg = Release|Any CPU + {0FAF1E6A-594A-4FDA-9F8D-B32AD299F808}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/dockerfile b/src/dockerfile similarity index 86% rename from dockerfile rename to src/dockerfile index d4e36001..39a82446 100644 --- a/dockerfile +++ b/src/dockerfile @@ -3,11 +3,11 @@ FROM mcr.microsoft.com/dotnet/sdk:3.1 AS build WORKDIR /app # copy csproj and restore as distinct layers -COPY ./src/*.csproj ./ +COPY ./src/TodoApi/*.csproj ./ RUN dotnet restore # copy everything else and build app -COPY ./src/ ./ +COPY ./src/TodoApi ./ RUN dotnet publish -c release -o /app # final stage/image diff --git a/tests/TodoApi.Tests/.idea/.idea.TodoApi.Tests.dir/.idea/indexLayout.xml b/tests/TodoApi.Tests/.idea/.idea.TodoApi.Tests.dir/.idea/indexLayout.xml new file mode 100644 index 00000000..7b08163c --- /dev/null +++ b/tests/TodoApi.Tests/.idea/.idea.TodoApi.Tests.dir/.idea/indexLayout.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/tests/TodoApi.Tests/.idea/.idea.TodoApi.Tests.dir/.idea/projectSettingsUpdater.xml b/tests/TodoApi.Tests/.idea/.idea.TodoApi.Tests.dir/.idea/projectSettingsUpdater.xml new file mode 100644 index 00000000..4bb9f4d2 --- /dev/null +++ b/tests/TodoApi.Tests/.idea/.idea.TodoApi.Tests.dir/.idea/projectSettingsUpdater.xml @@ -0,0 +1,6 @@ + + + + + \ No newline at end of file diff --git a/tests/TodoApi.Tests/.idea/.idea.TodoApi.Tests.dir/.idea/vcs.xml b/tests/TodoApi.Tests/.idea/.idea.TodoApi.Tests.dir/.idea/vcs.xml new file mode 100644 index 00000000..b2bdec2d --- /dev/null +++ b/tests/TodoApi.Tests/.idea/.idea.TodoApi.Tests.dir/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/tests/TodoApi.Tests/TodoApi.Tests.csproj b/tests/TodoApi.Tests/TodoApi.Tests.csproj new file mode 100644 index 00000000..e3e890e7 --- /dev/null +++ b/tests/TodoApi.Tests/TodoApi.Tests.csproj @@ -0,0 +1,24 @@ + + + + net7.0 + enable + enable + + false + + + + + + + runtime; build; native; contentfiles; analyzers; buildtransitive + all + + + runtime; build; native; contentfiles; analyzers; buildtransitive + all + + + + diff --git a/tests/TodoApi.Tests/TodoApiTests.cs b/tests/TodoApi.Tests/TodoApiTests.cs new file mode 100644 index 00000000..7c52bef5 --- /dev/null +++ b/tests/TodoApi.Tests/TodoApiTests.cs @@ -0,0 +1,9 @@ +namespace TodoApi.Tests; + +public class UnitTest1 +{ + [Fact] + public void Test1() + { + } +} \ No newline at end of file diff --git a/tests/TodoApi.Tests/Usings.cs b/tests/TodoApi.Tests/Usings.cs new file mode 100644 index 00000000..8c927eb7 --- /dev/null +++ b/tests/TodoApi.Tests/Usings.cs @@ -0,0 +1 @@ +global using Xunit; \ No newline at end of file From e0ed7bf305fc35b40580b99575f3f3732ae2194c Mon Sep 17 00:00:00 2001 From: Vasjen Date: Fri, 25 Aug 2023 22:22:52 +0400 Subject: [PATCH 8/8] update structure of the project --- src/TodoApi/.gitignore => .gitignore | 0 .../.idea/.gitignore | 13 --------- .../.idea/indexLayout.xml | 8 ----- .../.idea.VelvetechTestTask.dir/.idea/vcs.xml | 6 ---- .vscode/settings.json | 3 ++ TodoApiDTO.sln | 9 +++++- deployments/docker-compose.yaml | 2 +- src/TodoApi/Data/AppDbContext.cs | 10 +++---- .../Infrastructure/ErrorHandlingMiddleware.cs | 29 +++++++++++++++++-- .../Services/Interfaces/IRepository.cs | 6 ++-- .../Services/Interfaces/ITodoService.cs | 6 ++-- src/TodoApi/Services/ItemsRepository.cs | 14 +++++---- src/TodoApi/Services/TodoService.cs | 8 ++--- src/TodoApi/Startup.cs | 16 +++++++++- src/TodoApi/TodoApiDTO.csproj | 17 +++-------- src/TodoApiDTO.sln | 29 ------------------- src/dockerfile | 4 +-- .../.idea/indexLayout.xml | 8 ----- .../.idea/projectSettingsUpdater.xml | 6 ---- .../.idea.TodoApi.Tests.dir/.idea/vcs.xml | 6 ---- tests/TodoApi.Tests/TodoApi.Tests.csproj | 24 --------------- tests/TodoApi.Tests/TodoApiTests.cs | 9 ------ tests/TodoApi.Tests/Usings.cs | 1 - 23 files changed, 82 insertions(+), 152 deletions(-) rename src/TodoApi/.gitignore => .gitignore (100%) delete mode 100644 .idea/.idea.VelvetechTestTask.dir/.idea/.gitignore delete mode 100644 .idea/.idea.VelvetechTestTask.dir/.idea/indexLayout.xml delete mode 100644 .idea/.idea.VelvetechTestTask.dir/.idea/vcs.xml create mode 100644 .vscode/settings.json delete mode 100644 src/TodoApiDTO.sln delete mode 100644 tests/TodoApi.Tests/.idea/.idea.TodoApi.Tests.dir/.idea/indexLayout.xml delete mode 100644 tests/TodoApi.Tests/.idea/.idea.TodoApi.Tests.dir/.idea/projectSettingsUpdater.xml delete mode 100644 tests/TodoApi.Tests/.idea/.idea.TodoApi.Tests.dir/.idea/vcs.xml delete mode 100644 tests/TodoApi.Tests/TodoApi.Tests.csproj delete mode 100644 tests/TodoApi.Tests/TodoApiTests.cs delete mode 100644 tests/TodoApi.Tests/Usings.cs diff --git a/src/TodoApi/.gitignore b/.gitignore similarity index 100% rename from src/TodoApi/.gitignore rename to .gitignore diff --git a/.idea/.idea.VelvetechTestTask.dir/.idea/.gitignore b/.idea/.idea.VelvetechTestTask.dir/.idea/.gitignore deleted file mode 100644 index 72ebe883..00000000 --- a/.idea/.idea.VelvetechTestTask.dir/.idea/.gitignore +++ /dev/null @@ -1,13 +0,0 @@ -# Default ignored files -/shelf/ -/workspace.xml -# Rider ignored files -/.idea.VelvetechTestTask.iml -/contentModel.xml -/modules.xml -/projectSettingsUpdater.xml -# Editor-based HTTP Client requests -/httpRequests/ -# Datasource local storage ignored files -/dataSources/ -/dataSources.local.xml diff --git a/.idea/.idea.VelvetechTestTask.dir/.idea/indexLayout.xml b/.idea/.idea.VelvetechTestTask.dir/.idea/indexLayout.xml deleted file mode 100644 index 7b08163c..00000000 --- a/.idea/.idea.VelvetechTestTask.dir/.idea/indexLayout.xml +++ /dev/null @@ -1,8 +0,0 @@ - - - - - - - - \ No newline at end of file diff --git a/.idea/.idea.VelvetechTestTask.dir/.idea/vcs.xml b/.idea/.idea.VelvetechTestTask.dir/.idea/vcs.xml deleted file mode 100644 index 94a25f7f..00000000 --- a/.idea/.idea.VelvetechTestTask.dir/.idea/vcs.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 00000000..df5b2381 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,3 @@ +{ + "dotnet.defaultSolution": "TodoApiDTO.sln" +} \ No newline at end of file diff --git a/TodoApiDTO.sln b/TodoApiDTO.sln index d42e8af0..bb088ff1 100644 --- a/TodoApiDTO.sln +++ b/TodoApiDTO.sln @@ -3,7 +3,7 @@ Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio Version 16 VisualStudioVersion = 16.0.30002.166 MinimumVisualStudioVersion = 10.0.40219.1 -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TodoApiDTO", "TodoApiDTO.csproj", "{623124F9-F5BA-42DD-BC26-A1720774229C}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TodoApiDTO", ".\src\TodoApi\TodoApiDTO.csproj", "{623124F9-F5BA-42DD-BC26-A1720774229C}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -19,6 +19,10 @@ Global {0FAF1E6A-594A-4FDA-9F8D-B32AD299F808}.Debug|Any CPU.Build.0 = Debug|Any CPU {0FAF1E6A-594A-4FDA-9F8D-B32AD299F808}.Release|Any CPU.ActiveCfg = Release|Any CPU {0FAF1E6A-594A-4FDA-9F8D-B32AD299F808}.Release|Any CPU.Build.0 = Release|Any CPU + {ED312825-6F90-4170-A494-1AEFC4ACBAED}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {ED312825-6F90-4170-A494-1AEFC4ACBAED}.Debug|Any CPU.Build.0 = Debug|Any CPU + {ED312825-6F90-4170-A494-1AEFC4ACBAED}.Release|Any CPU.ActiveCfg = Release|Any CPU + {ED312825-6F90-4170-A494-1AEFC4ACBAED}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -26,4 +30,7 @@ Global GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {60984BC9-01D1-4B40-9733-E459B1231F96} EndGlobalSection + GlobalSection(NestedProjects) = preSolution + {ED312825-6F90-4170-A494-1AEFC4ACBAED} = {E0EE6CC2-8FCD-43B4-BAA1-E8A578F48AB0} + EndGlobalSection EndGlobal diff --git a/deployments/docker-compose.yaml b/deployments/docker-compose.yaml index 68c91d43..2232d8f2 100644 --- a/deployments/docker-compose.yaml +++ b/deployments/docker-compose.yaml @@ -2,7 +2,7 @@ version: '3.7' services: api: build: - context: ../ + context: ../src/ dockerfile: dockerfile ports: - 9000:80 diff --git a/src/TodoApi/Data/AppDbContext.cs b/src/TodoApi/Data/AppDbContext.cs index ffb9d3cf..af497e53 100644 --- a/src/TodoApi/Data/AppDbContext.cs +++ b/src/TodoApi/Data/AppDbContext.cs @@ -5,20 +5,18 @@ namespace TodoApi.Data{ public class AppDbContext : DbContext{ - private readonly IConfiguration _config; - public AppDbContext(DbContextOptions options, IConfiguration config) + public AppDbContext(DbContextOptions options) : base(options) { - _config = config; + } - public DbSet TodoItems { get; set; } + public virtual DbSet TodoItems { get; set; } protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) { - var connection = _config.GetConnectionString("ConnectionToDb"); - optionsBuilder.UseSqlServer(connection); + } protected override void OnModelCreating(ModelBuilder modelBuilder) { diff --git a/src/TodoApi/Infrastructure/ErrorHandlingMiddleware.cs b/src/TodoApi/Infrastructure/ErrorHandlingMiddleware.cs index 1c48af52..388af452 100644 --- a/src/TodoApi/Infrastructure/ErrorHandlingMiddleware.cs +++ b/src/TodoApi/Infrastructure/ErrorHandlingMiddleware.cs @@ -1,7 +1,30 @@ -namespace TodoApi.Infrastructure +using System; +using System.Threading.Tasks; +using Microsoft.AspNetCore.Http; +using Microsoft.Extensions.Logging; + +public class ErrorHandlingMiddleware { - public class ErrorHandlingMiddleware + private readonly RequestDelegate _next; + private readonly ILogger _logger; + + public ErrorHandlingMiddleware(RequestDelegate next, ILogger logger) { - + _next = next; + _logger = logger; + } + + public async Task Invoke(HttpContext context) + { + try + { + await _next(context); + } + catch (Exception ex) + { + _logger.LogError(ex, "Have an error"); + context.Response.StatusCode = StatusCodes.Status500InternalServerError; + await context.Response.WriteAsync("Have an error"); + } } } \ No newline at end of file diff --git a/src/TodoApi/Services/Interfaces/IRepository.cs b/src/TodoApi/Services/Interfaces/IRepository.cs index da83caee..ae15c676 100644 --- a/src/TodoApi/Services/Interfaces/IRepository.cs +++ b/src/TodoApi/Services/Interfaces/IRepository.cs @@ -8,9 +8,9 @@ public interface IRepository where T : class, IEntity { Task> GetItems(); Task GetItem(long id); - Task UpdateItem(T entity); - Task CreateItem(T entity); - Task DeleteTodoItem(long id); + Task UpdateItem(T entity); + Task CreateItem(T entity); + Task DeleteTodoItem(long id); Task IEntityExists(long id); } } \ No newline at end of file diff --git a/src/TodoApi/Services/Interfaces/ITodoService.cs b/src/TodoApi/Services/Interfaces/ITodoService.cs index fed5ae95..eca246c6 100644 --- a/src/TodoApi/Services/Interfaces/ITodoService.cs +++ b/src/TodoApi/Services/Interfaces/ITodoService.cs @@ -8,9 +8,9 @@ public interface ITodoService { Task> GetTodoItems(); Task GetTodoItem(long id); - Task UpdateTodoItem(long id, TodoItemDTO Item); - Task CreateTodoItem(TodoItemDTO Item); - Task DeleteTodoItem(long id); + Task UpdateTodoItem(long id, TodoItemDTO Item); + Task CreateTodoItem(TodoItemDTO Item); + Task DeleteTodoItem(long id); Task TodoItemExists(long id); } diff --git a/src/TodoApi/Services/ItemsRepository.cs b/src/TodoApi/Services/ItemsRepository.cs index bcb68e32..b8e83e8d 100644 --- a/src/TodoApi/Services/ItemsRepository.cs +++ b/src/TodoApi/Services/ItemsRepository.cs @@ -24,32 +24,36 @@ public async Task> GetItems() public async Task GetItem(long id) => await _context.Set().AsNoTracking().Where(p => p.Id == id).SingleAsync(); - public async Task UpdateItem(T entity) + public async Task UpdateItem(T entity) { if (entity == null) - throw new ArgumentNullException($"{nameof(entity)} cann't be a null"); + return false; _context.Set().Update(entity); await _context.SaveChangesAsync(); + return true; } - public async Task CreateItem(T entity) + public async Task CreateItem(T entity) { if (entity == null) throw new ArgumentNullException($"{nameof(entity)} cann't be a null"); await _context.Set().AddAsync(entity); await _context.SaveChangesAsync(); + return entity; } - public async Task DeleteTodoItem(long id) + public async Task DeleteTodoItem(long id) { var entity = await _context.Set().AsNoTracking().Where(p => p.Id == id).SingleAsync();; if (entity == null) - throw new NullReferenceException ($"{nameof(entity)} cann't be a null"); + return false; _context.Set().Remove(entity); await _context.SaveChangesAsync(); + + return true; } public async Task IEntityExists(long id) => diff --git a/src/TodoApi/Services/TodoService.cs b/src/TodoApi/Services/TodoService.cs index b2dbdc97..8cf3e42e 100644 --- a/src/TodoApi/Services/TodoService.cs +++ b/src/TodoApi/Services/TodoService.cs @@ -15,13 +15,13 @@ public TodoService(IRepository repository) _repository = repository; } - public Task CreateTodoItem(TodoItemDTO Item) + public Task CreateTodoItem(TodoItemDTO Item) { var todoItem = Item.AsEntity(); return _repository.CreateItem(todoItem); } - public async Task DeleteTodoItem(long id) + public async Task DeleteTodoItem(long id) => await _repository.DeleteTodoItem(id); public async Task GetTodoItem(long id) @@ -30,12 +30,12 @@ public async Task GetTodoItem(long id) public async Task> GetTodoItems() => await _repository.GetItems(); - public async Task UpdateTodoItem(long id, TodoItemDTO Item) + public async Task UpdateTodoItem(long id, TodoItemDTO Item) { var todoItem = await GetTodoItem(id); todoItem.Name = Item.Name; todoItem.IsComplete = Item.IsComplete; - await _repository.UpdateItem(todoItem); + return await _repository.UpdateItem(todoItem); } public Task TodoItemExists(long id) => _repository.IEntityExists(id); diff --git a/src/TodoApi/Startup.cs b/src/TodoApi/Startup.cs index 8453cbb0..a3223c43 100644 --- a/src/TodoApi/Startup.cs +++ b/src/TodoApi/Startup.cs @@ -6,9 +6,11 @@ using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Hosting; +using Microsoft.Extensions.Options; using Microsoft.OpenApi.Any; using Microsoft.OpenApi.Interfaces; using Microsoft.OpenApi.Models; +using Serilog; using TodoApi.Data; using TodoApi.Models; using TodoApi.Services; @@ -28,8 +30,20 @@ public Startup(IConfiguration configuration) // This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { - services.AddDbContext(); + services.AddDbContext((cfg) => + { + var connection = Configuration.GetConnectionString("ConnectionToDb"); + cfg.UseSqlServer(connection); + }); services.AddControllers(); + Log.Logger = new LoggerConfiguration() + .WriteTo.File("log.txt") + .CreateLogger(); + + services.AddLogging(loggingBuilder => + { + loggingBuilder.AddSerilog(); + }); services.AddScoped(typeof(IRepository<>), typeof(ItemsRepository<>)); services.AddScoped(); services.AddSwaggerGen(options => diff --git a/src/TodoApi/TodoApiDTO.csproj b/src/TodoApi/TodoApiDTO.csproj index 15507d00..95aa21d4 100644 --- a/src/TodoApi/TodoApiDTO.csproj +++ b/src/TodoApi/TodoApiDTO.csproj @@ -11,21 +11,12 @@ + + + - - - - - - runtime; build; native; contentfiles; analyzers; buildtransitive - all - - - runtime; build; native; contentfiles; analyzers; buildtransitive - all - - + \ No newline at end of file diff --git a/src/TodoApiDTO.sln b/src/TodoApiDTO.sln deleted file mode 100644 index d42e8af0..00000000 --- a/src/TodoApiDTO.sln +++ /dev/null @@ -1,29 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio Version 16 -VisualStudioVersion = 16.0.30002.166 -MinimumVisualStudioVersion = 10.0.40219.1 -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TodoApiDTO", "TodoApiDTO.csproj", "{623124F9-F5BA-42DD-BC26-A1720774229C}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Any CPU = Debug|Any CPU - Release|Any CPU = Release|Any CPU - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {623124F9-F5BA-42DD-BC26-A1720774229C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {623124F9-F5BA-42DD-BC26-A1720774229C}.Debug|Any CPU.Build.0 = Debug|Any CPU - {623124F9-F5BA-42DD-BC26-A1720774229C}.Release|Any CPU.ActiveCfg = Release|Any CPU - {623124F9-F5BA-42DD-BC26-A1720774229C}.Release|Any CPU.Build.0 = Release|Any CPU - {0FAF1E6A-594A-4FDA-9F8D-B32AD299F808}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {0FAF1E6A-594A-4FDA-9F8D-B32AD299F808}.Debug|Any CPU.Build.0 = Debug|Any CPU - {0FAF1E6A-594A-4FDA-9F8D-B32AD299F808}.Release|Any CPU.ActiveCfg = Release|Any CPU - {0FAF1E6A-594A-4FDA-9F8D-B32AD299F808}.Release|Any CPU.Build.0 = Release|Any CPU - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection - GlobalSection(ExtensibilityGlobals) = postSolution - SolutionGuid = {60984BC9-01D1-4B40-9733-E459B1231F96} - EndGlobalSection -EndGlobal diff --git a/src/dockerfile b/src/dockerfile index 39a82446..9cf4cb39 100644 --- a/src/dockerfile +++ b/src/dockerfile @@ -3,11 +3,11 @@ FROM mcr.microsoft.com/dotnet/sdk:3.1 AS build WORKDIR /app # copy csproj and restore as distinct layers -COPY ./src/TodoApi/*.csproj ./ +COPY ./TodoApi/*.csproj ./ RUN dotnet restore # copy everything else and build app -COPY ./src/TodoApi ./ +COPY ./TodoApi ./ RUN dotnet publish -c release -o /app # final stage/image diff --git a/tests/TodoApi.Tests/.idea/.idea.TodoApi.Tests.dir/.idea/indexLayout.xml b/tests/TodoApi.Tests/.idea/.idea.TodoApi.Tests.dir/.idea/indexLayout.xml deleted file mode 100644 index 7b08163c..00000000 --- a/tests/TodoApi.Tests/.idea/.idea.TodoApi.Tests.dir/.idea/indexLayout.xml +++ /dev/null @@ -1,8 +0,0 @@ - - - - - - - - \ No newline at end of file diff --git a/tests/TodoApi.Tests/.idea/.idea.TodoApi.Tests.dir/.idea/projectSettingsUpdater.xml b/tests/TodoApi.Tests/.idea/.idea.TodoApi.Tests.dir/.idea/projectSettingsUpdater.xml deleted file mode 100644 index 4bb9f4d2..00000000 --- a/tests/TodoApi.Tests/.idea/.idea.TodoApi.Tests.dir/.idea/projectSettingsUpdater.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - - \ No newline at end of file diff --git a/tests/TodoApi.Tests/.idea/.idea.TodoApi.Tests.dir/.idea/vcs.xml b/tests/TodoApi.Tests/.idea/.idea.TodoApi.Tests.dir/.idea/vcs.xml deleted file mode 100644 index b2bdec2d..00000000 --- a/tests/TodoApi.Tests/.idea/.idea.TodoApi.Tests.dir/.idea/vcs.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/tests/TodoApi.Tests/TodoApi.Tests.csproj b/tests/TodoApi.Tests/TodoApi.Tests.csproj deleted file mode 100644 index e3e890e7..00000000 --- a/tests/TodoApi.Tests/TodoApi.Tests.csproj +++ /dev/null @@ -1,24 +0,0 @@ - - - - net7.0 - enable - enable - - false - - - - - - - runtime; build; native; contentfiles; analyzers; buildtransitive - all - - - runtime; build; native; contentfiles; analyzers; buildtransitive - all - - - - diff --git a/tests/TodoApi.Tests/TodoApiTests.cs b/tests/TodoApi.Tests/TodoApiTests.cs deleted file mode 100644 index 7c52bef5..00000000 --- a/tests/TodoApi.Tests/TodoApiTests.cs +++ /dev/null @@ -1,9 +0,0 @@ -namespace TodoApi.Tests; - -public class UnitTest1 -{ - [Fact] - public void Test1() - { - } -} \ No newline at end of file diff --git a/tests/TodoApi.Tests/Usings.cs b/tests/TodoApi.Tests/Usings.cs deleted file mode 100644 index 8c927eb7..00000000 --- a/tests/TodoApi.Tests/Usings.cs +++ /dev/null @@ -1 +0,0 @@ -global using Xunit; \ No newline at end of file