From 766869a6d69a891532ed22525fa72db18a0761f6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tommy=20=C3=96man?= Date: Tue, 17 Dec 2019 20:44:55 +0100 Subject: [PATCH] Initial git push --- H_PLUS_Sports.sln | 25 +++ .../Controllers/CustomersController.cs | 85 +++++++++ .../Controllers/OrderItemsController.cs | 62 ++++++ H_PLUS_Sports/Controllers/OrdersController.cs | 61 ++++++ .../Controllers/ProductsController.cs | 61 ++++++ .../Controllers/SalespersonsController.cs | 61 ++++++ H_PLUS_Sports/H_PLUS_Sports.csproj | 18 ++ H_PLUS_Sports/Models/Customer.cs | 30 +++ H_PLUS_Sports/Models/H_Plus_SportsContext.cs | 180 ++++++++++++++++++ H_PLUS_Sports/Models/Order.cs | 28 +++ H_PLUS_Sports/Models/OrderItem.cs | 16 ++ H_PLUS_Sports/Models/Product.cs | 22 +++ H_PLUS_Sports/Models/Salesperson.cs | 25 +++ H_PLUS_Sports/Program.cs | 26 +++ H_PLUS_Sports/Properties/launchSettings.json | 29 +++ H_PLUS_Sports/Startup.cs | 55 ++++++ H_PLUS_Sports/WeatherForecast.cs | 15 ++ H_PLUS_Sports/appsettings.Development.json | 9 + H_PLUS_Sports/appsettings.json | 10 + 19 files changed, 818 insertions(+) create mode 100644 H_PLUS_Sports.sln create mode 100644 H_PLUS_Sports/Controllers/CustomersController.cs create mode 100644 H_PLUS_Sports/Controllers/OrderItemsController.cs create mode 100644 H_PLUS_Sports/Controllers/OrdersController.cs create mode 100644 H_PLUS_Sports/Controllers/ProductsController.cs create mode 100644 H_PLUS_Sports/Controllers/SalespersonsController.cs create mode 100644 H_PLUS_Sports/H_PLUS_Sports.csproj create mode 100644 H_PLUS_Sports/Models/Customer.cs create mode 100644 H_PLUS_Sports/Models/H_Plus_SportsContext.cs create mode 100644 H_PLUS_Sports/Models/Order.cs create mode 100644 H_PLUS_Sports/Models/OrderItem.cs create mode 100644 H_PLUS_Sports/Models/Product.cs create mode 100644 H_PLUS_Sports/Models/Salesperson.cs create mode 100644 H_PLUS_Sports/Program.cs create mode 100644 H_PLUS_Sports/Properties/launchSettings.json create mode 100644 H_PLUS_Sports/Startup.cs create mode 100644 H_PLUS_Sports/WeatherForecast.cs create mode 100644 H_PLUS_Sports/appsettings.Development.json create mode 100644 H_PLUS_Sports/appsettings.json diff --git a/H_PLUS_Sports.sln b/H_PLUS_Sports.sln new file mode 100644 index 0000000..b2d9199 --- /dev/null +++ b/H_PLUS_Sports.sln @@ -0,0 +1,25 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 16 +VisualStudioVersion = 16.0.29609.76 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "H_PLUS_Sports", "H_PLUS_Sports\H_PLUS_Sports.csproj", "{A5EEAD5D-227A-482E-AD66-F17D87C1E187}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {A5EEAD5D-227A-482E-AD66-F17D87C1E187}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {A5EEAD5D-227A-482E-AD66-F17D87C1E187}.Debug|Any CPU.Build.0 = Debug|Any CPU + {A5EEAD5D-227A-482E-AD66-F17D87C1E187}.Release|Any CPU.ActiveCfg = Release|Any CPU + {A5EEAD5D-227A-482E-AD66-F17D87C1E187}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {9E5C4E67-84F5-41E0-B246-265388B554AE} + EndGlobalSection +EndGlobal diff --git a/H_PLUS_Sports/Controllers/CustomersController.cs b/H_PLUS_Sports/Controllers/CustomersController.cs new file mode 100644 index 0000000..28ec25b --- /dev/null +++ b/H_PLUS_Sports/Controllers/CustomersController.cs @@ -0,0 +1,85 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Net; +using System.Threading.Tasks; +using H_PLUS_Sports.Models; +using Microsoft.AspNetCore.Http; +using Microsoft.AspNetCore.Mvc; +using Microsoft.EntityFrameworkCore; + +namespace H_PLUS_Sports.Controllers +{ + [Produces("application/json")] + [Route("api/Customers")] + // [ApiController] + public class CustomersController : ControllerBase + { + private readonly H_Plus_SportsContext _context; + + public CustomersController(H_Plus_SportsContext context) + { + _context = context; + } + + [HttpGet] + public IActionResult GetCustomer() + { + var results = new ObjectResult(_context.Customer) + { + StatusCode = (int)HttpStatusCode.OK + }; + Request.HttpContext.Response.Headers.Add("X-Total-Count", _context.Customer.Count().ToString()); + return results; + } + + [HttpGet("{id}", Name = "GetCustomer")] + public async Task GetCustomer([FromRoute] int id) + { + if ((CustomerExists(id))) + { + var customer = await _context.Customer.SingleOrDefaultAsync(m => m.CustomerId == id); + return Ok(customer); + } + else + { + return NotFound(); + } + } + + private bool CustomerExists(int id) + { + return _context.Customer.Any(c => c.CustomerId == id); + } + + [HttpPost] + public async Task PostCustomer([FromBody] Customer customer) + { + if (!ModelState.IsValid) + { + return BadRequest(ModelState); + } + _context.Customer.Add(customer); + await _context.SaveChangesAsync(); + return CreatedAtAction("getCustomer", new { id = customer.CustomerId }, customer); + } + + [HttpPut("{id}")] + public async Task PutCustomer([FromRoute] int id, [FromBody] Customer customer) + { + _context.Entry(customer).State = EntityState.Modified; + await _context.SaveChangesAsync(); + return Ok(customer); + } + + [HttpDelete("{id}")] + public async Task DeleteCustomer([FromRoute] int id) + { + var customer = await _context.Customer.SingleOrDefaultAsync(m => m.CustomerId == id); + _context.Customer.Remove(customer); + await _context.SaveChangesAsync(); + return Ok(customer); + } + + } +} \ No newline at end of file diff --git a/H_PLUS_Sports/Controllers/OrderItemsController.cs b/H_PLUS_Sports/Controllers/OrderItemsController.cs new file mode 100644 index 0000000..a7ec311 --- /dev/null +++ b/H_PLUS_Sports/Controllers/OrderItemsController.cs @@ -0,0 +1,62 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using H_PLUS_Sports.Models; +using Microsoft.AspNetCore.Http; +using Microsoft.AspNetCore.Mvc; +using Microsoft.EntityFrameworkCore; + +namespace HPlusSportsAPI.Controllers +{ + [Produces("application/json")] + [Route("api/OrderItems")] + public class OrderItemsController : Controller + { + private readonly H_Plus_SportsContext _context; + + public OrderItemsController(H_Plus_SportsContext context) + { + _context = context; + } + + [HttpGet] + public IActionResult GetOrderItem() + { + return new ObjectResult(_context.OrderItem); + } + + [HttpGet("{id}", Name = "GetOrderItem")] + public async Task GetOrderItem([FromRoute] int id) + { + var orderItem = await _context.OrderItem.SingleOrDefaultAsync(m => m.OrderItemId == id); + return Ok(orderItem); + } + + [HttpPost] + public async Task PostOrderItem([FromBody] OrderItem orderItem) + { + _context.OrderItem.Add(orderItem); + await _context.SaveChangesAsync(); + return CreatedAtAction("getOrderItem", new { id = orderItem.OrderItemId }, orderItem); + } + + [HttpPut("{id}")] + public async Task PutOrderItem([FromRoute] int id, [FromBody] OrderItem orderItem) + { + _context.Entry(orderItem).State = EntityState.Modified; + await _context.SaveChangesAsync(); + return Ok(orderItem); + } + + [HttpDelete("{id}")] + + public async Task DeleteOrderItem([FromRoute] int id) + { + var orderItem = await _context.OrderItem.SingleOrDefaultAsync(m => m.OrderItemId== id); + _context.OrderItem.Remove(orderItem); + await _context.SaveChangesAsync(); + return Ok(orderItem); + } + } +} \ No newline at end of file diff --git a/H_PLUS_Sports/Controllers/OrdersController.cs b/H_PLUS_Sports/Controllers/OrdersController.cs new file mode 100644 index 0000000..d178dfe --- /dev/null +++ b/H_PLUS_Sports/Controllers/OrdersController.cs @@ -0,0 +1,61 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using H_PLUS_Sports.Models; +using Microsoft.AspNetCore.Http; +using Microsoft.AspNetCore.Mvc; +using Microsoft.EntityFrameworkCore; + +namespace HPlusSportsAPI.Controllers +{ + [Produces("application/json")] + [Route("api/Orders")] + public class OrdersController : Controller + { + private readonly H_Plus_SportsContext _context; + + public OrdersController(H_Plus_SportsContext context) + { + _context = context; + } + + [HttpGet] + public IActionResult GetOrder() + { + return new ObjectResult(_context.Order); + } + + [HttpGet("{id}", Name = "GetOrder")] + public async Task GetOrder([FromRoute] int id) + { + var order = await _context.Order.SingleOrDefaultAsync(m => m.OrderId == id); + return Ok(order); + } + + [HttpPost] + public async Task PostOrder([FromBody] Order order) + { + _context.Add(order); + await _context.SaveChangesAsync(); + return CreatedAtAction("getOrder", new { id = order.OrderId }, order); + } + + [HttpPut("{id}")] + public async Task PutOrder([FromRoute] int id, [FromBody] Order order) + { + _context.Entry(order).State = EntityState.Modified; + await _context.SaveChangesAsync(); + return Ok(order); + } + + [HttpDelete("{id}")] + public async Task DeleteOrder([FromRoute] int id) + { + var order = await _context.Order.SingleOrDefaultAsync(m => m.OrderId== id); + _context.Order.Remove(order); + await _context.SaveChangesAsync(); + return Ok(order); + } + } +} \ No newline at end of file diff --git a/H_PLUS_Sports/Controllers/ProductsController.cs b/H_PLUS_Sports/Controllers/ProductsController.cs new file mode 100644 index 0000000..a5b9b3b --- /dev/null +++ b/H_PLUS_Sports/Controllers/ProductsController.cs @@ -0,0 +1,61 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using H_PLUS_Sports.Models; +using Microsoft.AspNetCore.Http; +using Microsoft.AspNetCore.Mvc; +using Microsoft.EntityFrameworkCore; + +namespace HPlusSportsAPI.Controllers +{ + [Produces("application/json")] + [Route("api/Products")] + public class ProductsController : Controller + { + private readonly H_Plus_SportsContext _context; + + public ProductsController(H_Plus_SportsContext context) + { + _context = context; + } + + [HttpGet] + public IActionResult GetProduct() + { + return new ObjectResult(_context.Product); + } + + [HttpGet("{id}", Name = "GetProduct")] + public async Task GetProduct([FromRoute] string id) + { + var product = await _context.Product.SingleOrDefaultAsync(m => m.ProductId == id); + return Ok(product); + } + + [HttpPost] + public async Task PostProduct([FromBody] Product product) + { + _context.Product.Add(product); + await _context.SaveChangesAsync(); + return CreatedAtAction("getProduct", new { id = product.ProductId }, product); + } + + [HttpPut("{id}")] + public async Task PutProduct([FromRoute] string id, [FromBody] Product product) + { + _context.Entry(product).State = EntityState.Modified; + await _context.SaveChangesAsync(); + return Ok(product); + } + + [HttpDelete("{id}")] + public async Task DeleteProduct([FromRoute] string id) + { + var product = await _context.Product.SingleOrDefaultAsync(m => m.ProductId == id); + _context.Product.Remove(product); + await _context.SaveChangesAsync(); + return Ok(product); + } + } +} \ No newline at end of file diff --git a/H_PLUS_Sports/Controllers/SalespersonsController.cs b/H_PLUS_Sports/Controllers/SalespersonsController.cs new file mode 100644 index 0000000..3f13fc1 --- /dev/null +++ b/H_PLUS_Sports/Controllers/SalespersonsController.cs @@ -0,0 +1,61 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using H_PLUS_Sports.Models; +using Microsoft.AspNetCore.Http; +using Microsoft.AspNetCore.Mvc; +using Microsoft.EntityFrameworkCore; + +namespace HPlusSportsAPI.Controllers +{ + [Produces("application/json")] + [Route("api/Salespersons")] + public class SalespersonsController : Controller + { + private readonly H_Plus_SportsContext _context; + + public SalespersonsController(H_Plus_SportsContext context) + { + _context = context; + } + + [HttpGet] + public IActionResult GetSalesperson() + { + return new ObjectResult(_context.Salesperson); + } + + [HttpGet("{id}", Name = "GetSalesPerson")] + public async Task GetSalesperson([FromRoute] int id) + { + var salesPerson = await _context.Salesperson.SingleOrDefaultAsync(m => m.SalespersonId== id); + return Ok(salesPerson); + } + + [HttpPost] + public async Task PostSalesperson([FromBody] Salesperson salesPerson) + { + _context.Salesperson.Add(salesPerson); + await _context.SaveChangesAsync(); + return CreatedAtAction("getSalesPerson", new { id = salesPerson.SalespersonId}, salesPerson); + } + + [HttpPut("{id}")] + public async Task PutSalesperson([FromRoute] int id, [FromBody] Salesperson salesPerson) + { + _context.Entry(salesPerson).State = EntityState.Modified; + await _context.SaveChangesAsync(); + return Ok(salesPerson); + } + + [HttpDelete("{id}")] + public async Task DeleteSalesperson([FromRoute] int id) + { + var salesPerson = await _context.Salesperson.SingleOrDefaultAsync(m => m.SalespersonId == id); + _context.Salesperson.Remove(salesPerson); + await _context.SaveChangesAsync(); + return Ok(salesPerson); + } + } +} \ No newline at end of file diff --git a/H_PLUS_Sports/H_PLUS_Sports.csproj b/H_PLUS_Sports/H_PLUS_Sports.csproj new file mode 100644 index 0000000..70cf3bc --- /dev/null +++ b/H_PLUS_Sports/H_PLUS_Sports.csproj @@ -0,0 +1,18 @@ + + + + netcoreapp3.1 + + + + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + + + + + + diff --git a/H_PLUS_Sports/Models/Customer.cs b/H_PLUS_Sports/Models/Customer.cs new file mode 100644 index 0000000..bd22b6f --- /dev/null +++ b/H_PLUS_Sports/Models/Customer.cs @@ -0,0 +1,30 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations; + +namespace H_PLUS_Sports.Models +{ + public partial class Customer + { + public Customer() + { + Order = new HashSet(); + } + + public int CustomerId { get; set; } + [StringLength(50)] + public string FirstName { get; set; } + [StringLength(50)] + public string LastName { get; set; } + [EmailAddress] + public string Email { get; set; } + [Phone] + public string Phone { get; set; } + public string Address { get; set; } + public string City { get; set; } + public string State { get; set; } + public string Zipcode { get; set; } + + public virtual ICollection Order { get; set; } + } +} diff --git a/H_PLUS_Sports/Models/H_Plus_SportsContext.cs b/H_PLUS_Sports/Models/H_Plus_SportsContext.cs new file mode 100644 index 0000000..d3f6098 --- /dev/null +++ b/H_PLUS_Sports/Models/H_Plus_SportsContext.cs @@ -0,0 +1,180 @@ +using System; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Metadata; + +namespace H_PLUS_Sports.Models +{ + public partial class H_Plus_SportsContext : DbContext + { + public H_Plus_SportsContext() + { + } + + public H_Plus_SportsContext(DbContextOptions options) + : base(options) + { + } + + public virtual DbSet Customer { get; set; } + public virtual DbSet Order { get; set; } + public virtual DbSet OrderItem { get; set; } + public virtual DbSet Product { get; set; } + public virtual DbSet Salesperson { get; set; } + + + protected override void OnModelCreating(ModelBuilder modelBuilder) + { + modelBuilder.Entity(entity => + { + entity.Property(e => e.CustomerId).HasColumnName("CustomerID"); + + entity.Property(e => e.Address) + .HasMaxLength(50) + .IsUnicode(false); + + entity.Property(e => e.City) + .HasMaxLength(50) + .IsUnicode(false); + + entity.Property(e => e.Email) + .HasMaxLength(50) + .IsUnicode(false); + + entity.Property(e => e.FirstName) + .HasMaxLength(50) + .IsUnicode(false); + + entity.Property(e => e.LastName) + .HasMaxLength(50) + .IsUnicode(false); + + entity.Property(e => e.Phone) + .HasMaxLength(50) + .IsUnicode(false); + + entity.Property(e => e.State) + .HasMaxLength(50) + .IsUnicode(false); + + entity.Property(e => e.Zipcode) + .HasMaxLength(50) + .IsUnicode(false); + }); + + modelBuilder.Entity(entity => + { + entity.Property(e => e.OrderId).HasColumnName("OrderID"); + + entity.Property(e => e.CustomerId).HasColumnName("CustomerID"); + + entity.Property(e => e.Date).HasColumnType("datetime"); + + entity.Property(e => e.SalespersonId).HasColumnName("SalespersonID"); + + entity.Property(e => e.Status) + .HasMaxLength(50) + .IsUnicode(false); + + entity.Property(e => e.TotalDue).HasColumnType("money"); + + entity.HasOne(d => d.Customer) + .WithMany(p => p.Order) + .HasForeignKey(d => d.CustomerId) + .OnDelete(DeleteBehavior.ClientSetNull) + .HasConstraintName("FK_Order_Customer"); + + entity.HasOne(d => d.Salesperson) + .WithMany(p => p.Order) + .HasForeignKey(d => d.SalespersonId) + .OnDelete(DeleteBehavior.ClientSetNull) + .HasConstraintName("FK_Order_Salesperson"); + }); + + modelBuilder.Entity(entity => + { + entity.Property(e => e.OrderItemId).HasColumnName("OrderItemID"); + + entity.Property(e => e.OrderId).HasColumnName("OrderID"); + + entity.Property(e => e.ProductId) + .IsRequired() + .HasColumnName("ProductID") + .HasMaxLength(10); + + entity.HasOne(d => d.Order) + .WithMany(p => p.OrderItem) + .HasForeignKey(d => d.OrderId) + .OnDelete(DeleteBehavior.ClientSetNull) + .HasConstraintName("FK_OrderItem_Order"); + + entity.HasOne(d => d.Product) + .WithMany(p => p.OrderItem) + .HasForeignKey(d => d.ProductId) + .OnDelete(DeleteBehavior.ClientSetNull) + .HasConstraintName("FK_OrderItem_Product1"); + }); + + modelBuilder.Entity(entity => + { + entity.Property(e => e.ProductId) + .HasColumnName("ProductID") + .HasMaxLength(10); + + entity.Property(e => e.Price).HasColumnType("money"); + + entity.Property(e => e.ProductName) + .HasMaxLength(50) + .IsUnicode(false); + + entity.Property(e => e.Status) + .HasMaxLength(50) + .IsUnicode(false); + + entity.Property(e => e.Variety) + .HasMaxLength(50) + .IsUnicode(false); + }); + + modelBuilder.Entity(entity => + { + entity.Property(e => e.SalespersonId).HasColumnName("SalespersonID"); + + entity.Property(e => e.Address) + .HasMaxLength(50) + .IsUnicode(false); + + entity.Property(e => e.City) + .HasMaxLength(50) + .IsUnicode(false); + + entity.Property(e => e.Email) + .HasMaxLength(50) + .IsUnicode(false); + + entity.Property(e => e.FirstName) + .HasMaxLength(50) + .IsUnicode(false); + + entity.Property(e => e.LastName) + .HasMaxLength(50) + .IsUnicode(false); + + entity.Property(e => e.Phone) + .HasMaxLength(50) + .IsUnicode(false); + + entity.Property(e => e.State) + .HasMaxLength(50) + .IsUnicode(false); + + entity.Property(e => e.Zipcode) + .HasMaxLength(50) + .IsUnicode(false); + }); + + OnModelCreatingPartial(modelBuilder); + } + + partial void OnModelCreatingPartial(ModelBuilder modelBuilder); + } +} diff --git a/H_PLUS_Sports/Models/Order.cs b/H_PLUS_Sports/Models/Order.cs new file mode 100644 index 0000000..02c2f2a --- /dev/null +++ b/H_PLUS_Sports/Models/Order.cs @@ -0,0 +1,28 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations; + +namespace H_PLUS_Sports.Models +{ + public partial class Order + { + public Order() + { + OrderItem = new HashSet(); + } + + public int OrderId { get; set; } + [Required] + [DataType(DataType.Date)] + public DateTime? Date { get; set; } + [Required] + public decimal? TotalDue { get; set; } + public string Status { get; set; } + public int CustomerId { get; set; } + public int SalespersonId { get; set; } + + public virtual Customer Customer { get; set; } + public virtual Salesperson Salesperson { get; set; } + public virtual ICollection OrderItem { get; set; } + } +} diff --git a/H_PLUS_Sports/Models/OrderItem.cs b/H_PLUS_Sports/Models/OrderItem.cs new file mode 100644 index 0000000..7fa3a35 --- /dev/null +++ b/H_PLUS_Sports/Models/OrderItem.cs @@ -0,0 +1,16 @@ +using System; +using System.Collections.Generic; + +namespace H_PLUS_Sports.Models +{ + public partial class OrderItem + { + public int OrderItemId { get; set; } + public int OrderId { get; set; } + public string ProductId { get; set; } + public int? Quantity { get; set; } + + public virtual Order Order { get; set; } + public virtual Product Product { get; set; } + } +} diff --git a/H_PLUS_Sports/Models/Product.cs b/H_PLUS_Sports/Models/Product.cs new file mode 100644 index 0000000..74ec98c --- /dev/null +++ b/H_PLUS_Sports/Models/Product.cs @@ -0,0 +1,22 @@ +using System; +using System.Collections.Generic; + +namespace H_PLUS_Sports.Models +{ + public partial class Product + { + public Product() + { + OrderItem = new HashSet(); + } + + public string ProductId { get; set; } + public string ProductName { get; set; } + public int? Size { get; set; } + public string Variety { get; set; } + public decimal? Price { get; set; } + public string Status { get; set; } + + public virtual ICollection OrderItem { get; set; } + } +} diff --git a/H_PLUS_Sports/Models/Salesperson.cs b/H_PLUS_Sports/Models/Salesperson.cs new file mode 100644 index 0000000..878638e --- /dev/null +++ b/H_PLUS_Sports/Models/Salesperson.cs @@ -0,0 +1,25 @@ +using System; +using System.Collections.Generic; + +namespace H_PLUS_Sports.Models +{ + public partial class Salesperson + { + public Salesperson() + { + Order = new HashSet(); + } + + public int SalespersonId { get; set; } + public string FirstName { get; set; } + public string LastName { get; set; } + public string Email { get; set; } + public string Phone { get; set; } + public string Address { get; set; } + public string City { get; set; } + public string State { get; set; } + public string Zipcode { get; set; } + + public virtual ICollection Order { get; set; } + } +} diff --git a/H_PLUS_Sports/Program.cs b/H_PLUS_Sports/Program.cs new file mode 100644 index 0000000..9242cc5 --- /dev/null +++ b/H_PLUS_Sports/Program.cs @@ -0,0 +1,26 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using Microsoft.AspNetCore.Hosting; +using Microsoft.Extensions.Configuration; +using Microsoft.Extensions.Hosting; +using Microsoft.Extensions.Logging; + +namespace H_PLUS_Sports +{ + 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/H_PLUS_Sports/Properties/launchSettings.json b/H_PLUS_Sports/Properties/launchSettings.json new file mode 100644 index 0000000..6e5b2c5 --- /dev/null +++ b/H_PLUS_Sports/Properties/launchSettings.json @@ -0,0 +1,29 @@ +{ + "iisSettings": { + "windowsAuthentication": false, + "anonymousAuthentication": true, + "iisExpress": { + "applicationUrl": "http://localhost:50683", + "sslPort": 44368 + } + }, + "$schema": "http://json.schemastore.org/launchsettings.json", + "profiles": { + "IIS Express": { + "commandName": "IISExpress", + "launchUrl": "weatherforecast", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + }, + "H_PLUS_Sports": { + "commandName": "Project", + "launchBrowser": true, + "launchUrl": "weatherforecast", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + }, + "applicationUrl": "https://localhost:5001;http://localhost:5000" + } + } +} \ No newline at end of file diff --git a/H_PLUS_Sports/Startup.cs b/H_PLUS_Sports/Startup.cs new file mode 100644 index 0000000..5ff68a4 --- /dev/null +++ b/H_PLUS_Sports/Startup.cs @@ -0,0 +1,55 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using H_PLUS_Sports.Models; +using Microsoft.AspNetCore.Builder; +using Microsoft.AspNetCore.Hosting; +using Microsoft.AspNetCore.HttpsPolicy; +using Microsoft.AspNetCore.Mvc; +using Microsoft.EntityFrameworkCore; +using Microsoft.Extensions.Configuration; +using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Hosting; +using Microsoft.Extensions.Logging; + +namespace H_PLUS_Sports +{ + public class Startup + { + public Startup(IConfiguration configuration) + { + Configuration = configuration; + } + + public IConfiguration Configuration { get; } + + // This method gets called by the runtime. Use this method to add services to the container. + public void ConfigureServices(IServiceCollection services) + { + services.AddControllers(); + var connection = "Server=tcp:hsportsoeman.database.windows.net,1433;Initial Catalog=H_Plus_Sports;Persist Security Info=False;User ID=saTfoman;Password=Jes@lin78;MultipleActiveResultSets=False;Encrypt=True;TrustServerCertificate=False;Connection Timeout=30;"; + services.AddDbContext(options => options.UseSqlServer(connection)); + } + + // 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.UseHttpsRedirection(); + + app.UseRouting(); + + app.UseAuthorization(); + + app.UseEndpoints(endpoints => + { + endpoints.MapControllers(); + }); + } + } +} diff --git a/H_PLUS_Sports/WeatherForecast.cs b/H_PLUS_Sports/WeatherForecast.cs new file mode 100644 index 0000000..b146042 --- /dev/null +++ b/H_PLUS_Sports/WeatherForecast.cs @@ -0,0 +1,15 @@ +using System; + +namespace H_PLUS_Sports +{ + 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/H_PLUS_Sports/appsettings.Development.json b/H_PLUS_Sports/appsettings.Development.json new file mode 100644 index 0000000..8983e0f --- /dev/null +++ b/H_PLUS_Sports/appsettings.Development.json @@ -0,0 +1,9 @@ +{ + "Logging": { + "LogLevel": { + "Default": "Information", + "Microsoft": "Warning", + "Microsoft.Hosting.Lifetime": "Information" + } + } +} diff --git a/H_PLUS_Sports/appsettings.json b/H_PLUS_Sports/appsettings.json new file mode 100644 index 0000000..d9d9a9b --- /dev/null +++ b/H_PLUS_Sports/appsettings.json @@ -0,0 +1,10 @@ +{ + "Logging": { + "LogLevel": { + "Default": "Information", + "Microsoft": "Warning", + "Microsoft.Hosting.Lifetime": "Information" + } + }, + "AllowedHosts": "*" +}