commit 1a9fd04f261585048c00fe956d00e3bcd847b369 Author: Charles Showalter Date: Mon May 9 14:41:15 2022 -0700 Initial commit diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..454729b --- /dev/null +++ b/.gitignore @@ -0,0 +1,4 @@ +obj +bin +appsettings.json +*.db \ No newline at end of file diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 0000000..42a7cbc --- /dev/null +++ b/.vscode/launch.json @@ -0,0 +1,35 @@ +{ + "version": "0.2.0", + "configurations": [ + { + // Use IntelliSense to find out which attributes exist for C# debugging + // Use hover for the description of the existing attributes + // For further information visit https://github.com/OmniSharp/omnisharp-vscode/blob/master/debugger-launchjson.md + "name": ".NET Core Launch (web)", + "type": "coreclr", + "request": "launch", + "preLaunchTask": "build", + // If you have changed target frameworks, make sure to update the program path. + "program": "${workspaceFolder}/API/bin/Debug/net6.0/API.dll", + "args": [], + "cwd": "${workspaceFolder}/API", + "stopAtEntry": false, + // Enable launching a web browser when ASP.NET Core starts. For more information: https://aka.ms/VSCode-CS-LaunchJson-WebBrowser + "serverReadyAction": { + "action": "openExternally", + "pattern": "\\bNow listening on:\\s+(https?://\\S+)" + }, + "env": { + "ASPNETCORE_ENVIRONMENT": "Development" + }, + "sourceFileMap": { + "/Views": "${workspaceFolder}/Views" + } + }, + { + "name": ".NET Core Attach", + "type": "coreclr", + "request": "attach" + } + ] +} \ No newline at end of file diff --git a/.vscode/tasks.json b/.vscode/tasks.json new file mode 100644 index 0000000..d1eb122 --- /dev/null +++ b/.vscode/tasks.json @@ -0,0 +1,41 @@ +{ + "version": "2.0.0", + "tasks": [ + { + "label": "build", + "command": "dotnet", + "type": "process", + "args": [ + "build", + "${workspaceFolder}/API/API.csproj", + "/property:GenerateFullPaths=true", + "/consoleloggerparameters:NoSummary" + ], + "problemMatcher": "$msCompile" + }, + { + "label": "publish", + "command": "dotnet", + "type": "process", + "args": [ + "publish", + "${workspaceFolder}/API/API.csproj", + "/property:GenerateFullPaths=true", + "/consoleloggerparameters:NoSummary" + ], + "problemMatcher": "$msCompile" + }, + { + "label": "watch", + "command": "dotnet", + "type": "process", + "args": [ + "watch", + "run", + "--project", + "${workspaceFolder}/API/API.csproj" + ], + "problemMatcher": "$msCompile" + } + ] +} \ No newline at end of file diff --git a/API/API.csproj b/API/API.csproj new file mode 100644 index 0000000..9c4628b --- /dev/null +++ b/API/API.csproj @@ -0,0 +1,22 @@ + + + + net6.0 + enable + + + + + + runtime; build; native; contentfiles; analyzers; buildtransitive + all + + + + + + + + + + diff --git a/API/Controllers/ProductsController.cs b/API/Controllers/ProductsController.cs new file mode 100644 index 0000000..f01f3e2 --- /dev/null +++ b/API/Controllers/ProductsController.cs @@ -0,0 +1,32 @@ +using Infrastucture.Data; +using Core.Entities; +using Microsoft.AspNetCore.Mvc; +using Microsoft.EntityFrameworkCore; + +namespace API.Controllers +{ + [ApiController] + [Route("api/[controller]")] + public class ProductsController : ControllerBase + { + private readonly StoreContext _context; + public ProductsController(StoreContext context) + { + _context = context; + } + + [HttpGet] + public async Task>> GetProducts() + { + var products = await _context.Products.ToListAsync(); + + return Ok(products); + } + + [HttpGet("{id}")] + public async Task> GetProduct(int id) + { + return await _context.Products.FindAsync(id); + } + } +} \ No newline at end of file diff --git a/API/Controllers/WeatherForecastController.cs b/API/Controllers/WeatherForecastController.cs new file mode 100644 index 0000000..b879c25 --- /dev/null +++ b/API/Controllers/WeatherForecastController.cs @@ -0,0 +1,32 @@ +using Microsoft.AspNetCore.Mvc; + +namespace API.Controllers; + +[ApiController] +[Route("[controller]")] +public class WeatherForecastController : ControllerBase +{ + private static readonly string[] Summaries = new[] + { + "Freezing", "Bracing", "Chilly", "Cool", "Mild", "Warm", "Balmy", "Hot", "Sweltering", "Scorching" + }; + + private readonly ILogger _logger; + + public WeatherForecastController(ILogger logger) + { + _logger = logger; + } + + [HttpGet(Name = "GetWeatherForecast")] + public IEnumerable Get() + { + return Enumerable.Range(1, 5).Select(index => new WeatherForecast + { + Date = DateTime.Now.AddDays(index), + TemperatureC = Random.Shared.Next(-20, 55), + Summary = Summaries[Random.Shared.Next(Summaries.Length)] + }) + .ToArray(); + } +} diff --git a/API/Program.cs b/API/Program.cs new file mode 100644 index 0000000..f606381 --- /dev/null +++ b/API/Program.cs @@ -0,0 +1,17 @@ +namespace API +{ + public class Program + { + public static void Main(string[] args) + { + CreateHostBuilder(args).Build().Run(); + } + + public static IHostBuilder CreateHostBuilder(string[] args) => + Host.CreateDefaultBuilder(args) + .ConfigureWebHostDefaults(webBuilder => + { + webBuilder.UseStartup(); + }); + } +} diff --git a/API/Properties/launchSettings.json b/API/Properties/launchSettings.json new file mode 100644 index 0000000..dec3d93 --- /dev/null +++ b/API/Properties/launchSettings.json @@ -0,0 +1,31 @@ +{ + "$schema": "https://json.schemastore.org/launchsettings.json", + "iisSettings": { + "windowsAuthentication": false, + "anonymousAuthentication": true, + "iisExpress": { + "applicationUrl": "http://localhost:45380", + "sslPort": 44391 + } + }, + "profiles": { + "API": { + "commandName": "Project", + "dotnetRunMessages": true, + "launchBrowser": false, + "launchUrl": "swagger", + "applicationUrl": "https://localhost:5001;http://localhost:5000", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + }, + "IIS Express": { + "commandName": "IISExpress", + "launchBrowser": true, + "launchUrl": "swagger", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + } + } +} diff --git a/API/Startup.cs b/API/Startup.cs new file mode 100644 index 0000000..d3b6a29 --- /dev/null +++ b/API/Startup.cs @@ -0,0 +1,50 @@ +using Infrastucture.Data; +using Microsoft.EntityFrameworkCore; +using Microsoft.OpenApi.Models; + +namespace API +{ + public class Startup + { + private readonly IConfiguration _config; + public Startup(IConfiguration config) + { + _config = config; + } + + + // This method gets called by the runtime. Use this method to add services to the container. + public void ConfigureServices(IServiceCollection services) + { + + services.AddControllers(); + services.AddDbContext(x => x.UseSqlite(_config.GetConnectionString("DefaultConnection"))); + services.AddSwaggerGen(c => + { + c.SwaggerDoc("v1", new OpenApiInfo { Title = "WebAPIv5", Version = "v1" }); + }); + } + + // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. + public void Configure(IApplicationBuilder app, IWebHostEnvironment env) + { + if (env.IsDevelopment()) + { + app.UseDeveloperExceptionPage(); + app.UseSwagger(); + app.UseSwaggerUI(c => c.SwaggerEndpoint("/swagger/v1/swagger.json", "WebAPIv5 v1")); + } + + app.UseHttpsRedirection(); + + app.UseRouting(); + + app.UseAuthorization(); + + app.UseEndpoints(endpoints => + { + endpoints.MapControllers(); + }); + } + } +} diff --git a/API/WeatherForecast.cs b/API/WeatherForecast.cs new file mode 100644 index 0000000..8cd5ab0 --- /dev/null +++ b/API/WeatherForecast.cs @@ -0,0 +1,14 @@ +using System; + +namespace API; + +public class WeatherForecast +{ + public DateTime Date { get; set; } + + public int TemperatureC { get; set; } + + public int TemperatureF => 32 + (int)(TemperatureC / 0.5556); + + public string Summary { get; set; } +} diff --git a/API/appsettings.Development.json b/API/appsettings.Development.json new file mode 100644 index 0000000..cf133aa --- /dev/null +++ b/API/appsettings.Development.json @@ -0,0 +1,11 @@ +{ + "Logging": { + "LogLevel": { + "Default": "Information", + "Microsoft.AspNetCore": "Warning" + } + }, + "ConnectionStrings": { + "DefaultConnection": "Data source=ecommerce.db" + } +} diff --git a/API/ecommerce.db b/API/ecommerce.db new file mode 100644 index 0000000..f47dc38 Binary files /dev/null and b/API/ecommerce.db differ diff --git a/API/ecommerce.db-shm b/API/ecommerce.db-shm new file mode 100644 index 0000000..09e3ea4 Binary files /dev/null and b/API/ecommerce.db-shm differ diff --git a/API/ecommerce.db-wal b/API/ecommerce.db-wal new file mode 100644 index 0000000..583b3a8 Binary files /dev/null and b/API/ecommerce.db-wal differ diff --git a/Core/Core.csproj b/Core/Core.csproj new file mode 100644 index 0000000..d215c71 --- /dev/null +++ b/Core/Core.csproj @@ -0,0 +1,8 @@ + + + + net6.0 + enable + + + diff --git a/Core/Entities/Product.cs b/Core/Entities/Product.cs new file mode 100644 index 0000000..c34544a --- /dev/null +++ b/Core/Entities/Product.cs @@ -0,0 +1,8 @@ +namespace Core.Entities +{ + public class Product + { + public int Id { get; set; } + public string Name { get; set; } + } +} \ No newline at end of file diff --git a/E-Commerce.sln b/E-Commerce.sln new file mode 100644 index 0000000..7828964 --- /dev/null +++ b/E-Commerce.sln @@ -0,0 +1,34 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 16 +VisualStudioVersion = 16.0.30114.105 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "API", "API\API.csproj", "{B50BBAB5-56F7-46B3-B2B0-FE4831B956CD}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Core", "Core\Core.csproj", "{124DD725-C323-44B3-B490-0D3613FE6AFB}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Infrastucture", "Infrastucture\Infrastucture.csproj", "{D2AA653B-A7B8-4365-9D72-213F87B67175}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {B50BBAB5-56F7-46B3-B2B0-FE4831B956CD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {B50BBAB5-56F7-46B3-B2B0-FE4831B956CD}.Debug|Any CPU.Build.0 = Debug|Any CPU + {B50BBAB5-56F7-46B3-B2B0-FE4831B956CD}.Release|Any CPU.ActiveCfg = Release|Any CPU + {B50BBAB5-56F7-46B3-B2B0-FE4831B956CD}.Release|Any CPU.Build.0 = Release|Any CPU + {124DD725-C323-44B3-B490-0D3613FE6AFB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {124DD725-C323-44B3-B490-0D3613FE6AFB}.Debug|Any CPU.Build.0 = Debug|Any CPU + {124DD725-C323-44B3-B490-0D3613FE6AFB}.Release|Any CPU.ActiveCfg = Release|Any CPU + {124DD725-C323-44B3-B490-0D3613FE6AFB}.Release|Any CPU.Build.0 = Release|Any CPU + {D2AA653B-A7B8-4365-9D72-213F87B67175}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {D2AA653B-A7B8-4365-9D72-213F87B67175}.Debug|Any CPU.Build.0 = Debug|Any CPU + {D2AA653B-A7B8-4365-9D72-213F87B67175}.Release|Any CPU.ActiveCfg = Release|Any CPU + {D2AA653B-A7B8-4365-9D72-213F87B67175}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection +EndGlobal diff --git a/Infrastucture/Data/Migrations/20220509191604_InitialCreate.Designer.cs b/Infrastucture/Data/Migrations/20220509191604_InitialCreate.Designer.cs new file mode 100644 index 0000000..e7dfbb0 --- /dev/null +++ b/Infrastucture/Data/Migrations/20220509191604_InitialCreate.Designer.cs @@ -0,0 +1,37 @@ +// +using API.Data; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; + +#nullable disable + +namespace Infrastucture.Data.Migrations +{ + [DbContext(typeof(StoreContext))] + [Migration("20220509191604_InitialCreate")] + partial class InitialCreate + { + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder.HasAnnotation("ProductVersion", "6.0.4"); + + modelBuilder.Entity("API.Entities.Product", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("Name") + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.ToTable("Products"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/Infrastucture/Data/Migrations/20220509191604_InitialCreate.cs b/Infrastucture/Data/Migrations/20220509191604_InitialCreate.cs new file mode 100644 index 0000000..44f3174 --- /dev/null +++ b/Infrastucture/Data/Migrations/20220509191604_InitialCreate.cs @@ -0,0 +1,31 @@ +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace Infrastucture.Data.Migrations +{ + public partial class InitialCreate : Migration + { + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.CreateTable( + name: "Products", + columns: table => new + { + Id = table.Column(type: "INTEGER", nullable: false) + .Annotation("Sqlite:Autoincrement", true), + Name = table.Column(type: "TEXT", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_Products", x => x.Id); + }); + } + + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropTable( + name: "Products"); + } + } +} diff --git a/Infrastucture/Data/Migrations/StoreContextModelSnapshot.cs b/Infrastucture/Data/Migrations/StoreContextModelSnapshot.cs new file mode 100644 index 0000000..65f2453 --- /dev/null +++ b/Infrastucture/Data/Migrations/StoreContextModelSnapshot.cs @@ -0,0 +1,35 @@ +// +using Infrastucture.Data; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; + +#nullable disable + +namespace API.Data.Migrations +{ + [DbContext(typeof(StoreContext))] + partial class StoreContextModelSnapshot : ModelSnapshot + { + protected override void BuildModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder.HasAnnotation("ProductVersion", "6.0.4"); + + modelBuilder.Entity("API.Entities.Product", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("Name") + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.ToTable("Products"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/Infrastucture/Data/StoreContext.cs b/Infrastucture/Data/StoreContext.cs new file mode 100644 index 0000000..55af113 --- /dev/null +++ b/Infrastucture/Data/StoreContext.cs @@ -0,0 +1,13 @@ +using Core.Entities; +using Microsoft.EntityFrameworkCore; + +namespace Infrastucture.Data +{ + public class StoreContext : DbContext + { + public StoreContext(DbContextOptions options) : base(options) + { + } + public DbSet Products { get; set; } + } +} \ No newline at end of file diff --git a/Infrastucture/Infrastucture.csproj b/Infrastucture/Infrastucture.csproj new file mode 100644 index 0000000..269da8a --- /dev/null +++ b/Infrastucture/Infrastucture.csproj @@ -0,0 +1,16 @@ + + + + + + + + + + + + net6.0 + enable + + + diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..2071b23 --- /dev/null +++ b/LICENSE @@ -0,0 +1,9 @@ +MIT License + +Copyright (c) + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/README.md b/README.md new file mode 100644 index 0000000..c92c4df --- /dev/null +++ b/README.md @@ -0,0 +1,3 @@ +# E-Commerce + +Built upon .NET, Angular, and Bootstrap \ No newline at end of file