Initial git push
This commit is contained in:
25
H_PLUS_Sports.sln
Normal file
25
H_PLUS_Sports.sln
Normal file
@ -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
|
||||
85
H_PLUS_Sports/Controllers/CustomersController.cs
Normal file
85
H_PLUS_Sports/Controllers/CustomersController.cs
Normal file
@ -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<IActionResult> 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<IActionResult> 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<IActionResult> PutCustomer([FromRoute] int id, [FromBody] Customer customer)
|
||||
{
|
||||
_context.Entry(customer).State = EntityState.Modified;
|
||||
await _context.SaveChangesAsync();
|
||||
return Ok(customer);
|
||||
}
|
||||
|
||||
[HttpDelete("{id}")]
|
||||
public async Task<IActionResult> DeleteCustomer([FromRoute] int id)
|
||||
{
|
||||
var customer = await _context.Customer.SingleOrDefaultAsync(m => m.CustomerId == id);
|
||||
_context.Customer.Remove(customer);
|
||||
await _context.SaveChangesAsync();
|
||||
return Ok(customer);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
62
H_PLUS_Sports/Controllers/OrderItemsController.cs
Normal file
62
H_PLUS_Sports/Controllers/OrderItemsController.cs
Normal file
@ -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<IActionResult> GetOrderItem([FromRoute] int id)
|
||||
{
|
||||
var orderItem = await _context.OrderItem.SingleOrDefaultAsync(m => m.OrderItemId == id);
|
||||
return Ok(orderItem);
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public async Task<IActionResult> PostOrderItem([FromBody] OrderItem orderItem)
|
||||
{
|
||||
_context.OrderItem.Add(orderItem);
|
||||
await _context.SaveChangesAsync();
|
||||
return CreatedAtAction("getOrderItem", new { id = orderItem.OrderItemId }, orderItem);
|
||||
}
|
||||
|
||||
[HttpPut("{id}")]
|
||||
public async Task<IActionResult> PutOrderItem([FromRoute] int id, [FromBody] OrderItem orderItem)
|
||||
{
|
||||
_context.Entry(orderItem).State = EntityState.Modified;
|
||||
await _context.SaveChangesAsync();
|
||||
return Ok(orderItem);
|
||||
}
|
||||
|
||||
[HttpDelete("{id}")]
|
||||
|
||||
public async Task<IActionResult> DeleteOrderItem([FromRoute] int id)
|
||||
{
|
||||
var orderItem = await _context.OrderItem.SingleOrDefaultAsync(m => m.OrderItemId== id);
|
||||
_context.OrderItem.Remove(orderItem);
|
||||
await _context.SaveChangesAsync();
|
||||
return Ok(orderItem);
|
||||
}
|
||||
}
|
||||
}
|
||||
61
H_PLUS_Sports/Controllers/OrdersController.cs
Normal file
61
H_PLUS_Sports/Controllers/OrdersController.cs
Normal file
@ -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<IActionResult> GetOrder([FromRoute] int id)
|
||||
{
|
||||
var order = await _context.Order.SingleOrDefaultAsync(m => m.OrderId == id);
|
||||
return Ok(order);
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public async Task<IActionResult> PostOrder([FromBody] Order order)
|
||||
{
|
||||
_context.Add(order);
|
||||
await _context.SaveChangesAsync();
|
||||
return CreatedAtAction("getOrder", new { id = order.OrderId }, order);
|
||||
}
|
||||
|
||||
[HttpPut("{id}")]
|
||||
public async Task<IActionResult> PutOrder([FromRoute] int id, [FromBody] Order order)
|
||||
{
|
||||
_context.Entry(order).State = EntityState.Modified;
|
||||
await _context.SaveChangesAsync();
|
||||
return Ok(order);
|
||||
}
|
||||
|
||||
[HttpDelete("{id}")]
|
||||
public async Task<IActionResult> DeleteOrder([FromRoute] int id)
|
||||
{
|
||||
var order = await _context.Order.SingleOrDefaultAsync(m => m.OrderId== id);
|
||||
_context.Order.Remove(order);
|
||||
await _context.SaveChangesAsync();
|
||||
return Ok(order);
|
||||
}
|
||||
}
|
||||
}
|
||||
61
H_PLUS_Sports/Controllers/ProductsController.cs
Normal file
61
H_PLUS_Sports/Controllers/ProductsController.cs
Normal file
@ -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<IActionResult> GetProduct([FromRoute] string id)
|
||||
{
|
||||
var product = await _context.Product.SingleOrDefaultAsync(m => m.ProductId == id);
|
||||
return Ok(product);
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public async Task<IActionResult> PostProduct([FromBody] Product product)
|
||||
{
|
||||
_context.Product.Add(product);
|
||||
await _context.SaveChangesAsync();
|
||||
return CreatedAtAction("getProduct", new { id = product.ProductId }, product);
|
||||
}
|
||||
|
||||
[HttpPut("{id}")]
|
||||
public async Task<IActionResult> PutProduct([FromRoute] string id, [FromBody] Product product)
|
||||
{
|
||||
_context.Entry(product).State = EntityState.Modified;
|
||||
await _context.SaveChangesAsync();
|
||||
return Ok(product);
|
||||
}
|
||||
|
||||
[HttpDelete("{id}")]
|
||||
public async Task<IActionResult> DeleteProduct([FromRoute] string id)
|
||||
{
|
||||
var product = await _context.Product.SingleOrDefaultAsync(m => m.ProductId == id);
|
||||
_context.Product.Remove(product);
|
||||
await _context.SaveChangesAsync();
|
||||
return Ok(product);
|
||||
}
|
||||
}
|
||||
}
|
||||
61
H_PLUS_Sports/Controllers/SalespersonsController.cs
Normal file
61
H_PLUS_Sports/Controllers/SalespersonsController.cs
Normal file
@ -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<IActionResult> GetSalesperson([FromRoute] int id)
|
||||
{
|
||||
var salesPerson = await _context.Salesperson.SingleOrDefaultAsync(m => m.SalespersonId== id);
|
||||
return Ok(salesPerson);
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public async Task<IActionResult> PostSalesperson([FromBody] Salesperson salesPerson)
|
||||
{
|
||||
_context.Salesperson.Add(salesPerson);
|
||||
await _context.SaveChangesAsync();
|
||||
return CreatedAtAction("getSalesPerson", new { id = salesPerson.SalespersonId}, salesPerson);
|
||||
}
|
||||
|
||||
[HttpPut("{id}")]
|
||||
public async Task<IActionResult> PutSalesperson([FromRoute] int id, [FromBody] Salesperson salesPerson)
|
||||
{
|
||||
_context.Entry(salesPerson).State = EntityState.Modified;
|
||||
await _context.SaveChangesAsync();
|
||||
return Ok(salesPerson);
|
||||
}
|
||||
|
||||
[HttpDelete("{id}")]
|
||||
public async Task<IActionResult> DeleteSalesperson([FromRoute] int id)
|
||||
{
|
||||
var salesPerson = await _context.Salesperson.SingleOrDefaultAsync(m => m.SalespersonId == id);
|
||||
_context.Salesperson.Remove(salesPerson);
|
||||
await _context.SaveChangesAsync();
|
||||
return Ok(salesPerson);
|
||||
}
|
||||
}
|
||||
}
|
||||
18
H_PLUS_Sports/H_PLUS_Sports.csproj
Normal file
18
H_PLUS_Sports/H_PLUS_Sports.csproj
Normal file
@ -0,0 +1,18 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk.Web">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>netcoreapp3.1</TargetFramework>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="3.1.0" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="3.1.0">
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
</PackageReference>
|
||||
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="3.1.0" />
|
||||
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="3.1.0" />
|
||||
</ItemGroup>
|
||||
|
||||
|
||||
</Project>
|
||||
30
H_PLUS_Sports/Models/Customer.cs
Normal file
30
H_PLUS_Sports/Models/Customer.cs
Normal file
@ -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<Order>();
|
||||
}
|
||||
|
||||
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> Order { get; set; }
|
||||
}
|
||||
}
|
||||
180
H_PLUS_Sports/Models/H_Plus_SportsContext.cs
Normal file
180
H_PLUS_Sports/Models/H_Plus_SportsContext.cs
Normal file
@ -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<H_Plus_SportsContext> options)
|
||||
: base(options)
|
||||
{
|
||||
}
|
||||
|
||||
public virtual DbSet<Customer> Customer { get; set; }
|
||||
public virtual DbSet<Order> Order { get; set; }
|
||||
public virtual DbSet<OrderItem> OrderItem { get; set; }
|
||||
public virtual DbSet<Product> Product { get; set; }
|
||||
public virtual DbSet<Salesperson> Salesperson { get; set; }
|
||||
|
||||
|
||||
protected override void OnModelCreating(ModelBuilder modelBuilder)
|
||||
{
|
||||
modelBuilder.Entity<Customer>(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<Order>(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<OrderItem>(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<Product>(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<Salesperson>(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);
|
||||
}
|
||||
}
|
||||
28
H_PLUS_Sports/Models/Order.cs
Normal file
28
H_PLUS_Sports/Models/Order.cs
Normal file
@ -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<OrderItem>();
|
||||
}
|
||||
|
||||
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> OrderItem { get; set; }
|
||||
}
|
||||
}
|
||||
16
H_PLUS_Sports/Models/OrderItem.cs
Normal file
16
H_PLUS_Sports/Models/OrderItem.cs
Normal file
@ -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; }
|
||||
}
|
||||
}
|
||||
22
H_PLUS_Sports/Models/Product.cs
Normal file
22
H_PLUS_Sports/Models/Product.cs
Normal file
@ -0,0 +1,22 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace H_PLUS_Sports.Models
|
||||
{
|
||||
public partial class Product
|
||||
{
|
||||
public Product()
|
||||
{
|
||||
OrderItem = new HashSet<OrderItem>();
|
||||
}
|
||||
|
||||
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> OrderItem { get; set; }
|
||||
}
|
||||
}
|
||||
25
H_PLUS_Sports/Models/Salesperson.cs
Normal file
25
H_PLUS_Sports/Models/Salesperson.cs
Normal file
@ -0,0 +1,25 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace H_PLUS_Sports.Models
|
||||
{
|
||||
public partial class Salesperson
|
||||
{
|
||||
public Salesperson()
|
||||
{
|
||||
Order = new HashSet<Order>();
|
||||
}
|
||||
|
||||
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> Order { get; set; }
|
||||
}
|
||||
}
|
||||
26
H_PLUS_Sports/Program.cs
Normal file
26
H_PLUS_Sports/Program.cs
Normal file
@ -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<Startup>();
|
||||
});
|
||||
}
|
||||
}
|
||||
29
H_PLUS_Sports/Properties/launchSettings.json
Normal file
29
H_PLUS_Sports/Properties/launchSettings.json
Normal file
@ -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"
|
||||
}
|
||||
}
|
||||
}
|
||||
55
H_PLUS_Sports/Startup.cs
Normal file
55
H_PLUS_Sports/Startup.cs
Normal file
@ -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<H_Plus_SportsContext>(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();
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
15
H_PLUS_Sports/WeatherForecast.cs
Normal file
15
H_PLUS_Sports/WeatherForecast.cs
Normal file
@ -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; }
|
||||
}
|
||||
}
|
||||
9
H_PLUS_Sports/appsettings.Development.json
Normal file
9
H_PLUS_Sports/appsettings.Development.json
Normal file
@ -0,0 +1,9 @@
|
||||
{
|
||||
"Logging": {
|
||||
"LogLevel": {
|
||||
"Default": "Information",
|
||||
"Microsoft": "Warning",
|
||||
"Microsoft.Hosting.Lifetime": "Information"
|
||||
}
|
||||
}
|
||||
}
|
||||
10
H_PLUS_Sports/appsettings.json
Normal file
10
H_PLUS_Sports/appsettings.json
Normal file
@ -0,0 +1,10 @@
|
||||
{
|
||||
"Logging": {
|
||||
"LogLevel": {
|
||||
"Default": "Information",
|
||||
"Microsoft": "Warning",
|
||||
"Microsoft.Hosting.Lifetime": "Information"
|
||||
}
|
||||
},
|
||||
"AllowedHosts": "*"
|
||||
}
|
||||
Reference in New Issue
Block a user