Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions Api.eCommerce/Api.eCommerce.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.9.34723.18
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Api.eCommerce", "Api.eCommerce\Api.eCommerce.csproj", "{F7676AFD-7712-44DE-8F6E-558221D34E23}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{F7676AFD-7712-44DE-8F6E-558221D34E23}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{F7676AFD-7712-44DE-8F6E-558221D34E23}.Debug|Any CPU.Build.0 = Debug|Any CPU
{F7676AFD-7712-44DE-8F6E-558221D34E23}.Release|Any CPU.ActiveCfg = Release|Any CPU
{F7676AFD-7712-44DE-8F6E-558221D34E23}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {B695E2FA-3851-4437-854F-908FEA78AEE7}
EndGlobalSection
EndGlobal
19 changes: 19 additions & 0 deletions Api.eCommerce/Api.eCommerce/Api.eCommerce.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<Project Sdk="Microsoft.NET.Sdk.Web">

<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.4.0" />
</ItemGroup>

<ItemGroup>
<Reference Include="Library.eCommerce">
<HintPath>..\..\Library.eCommerce\bin\Debug\net8.0\Library.eCommerce.dll</HintPath>
</Reference>
</ItemGroup>

</Project>
6 changes: 6 additions & 0 deletions Api.eCommerce/Api.eCommerce/Api.eCommerce.http
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
@Api.eCommerce_HostAddress = http://localhost:5149

GET {{Api.eCommerce_HostAddress}}/weatherforecast/
Accept: application/json

###
31 changes: 31 additions & 0 deletions Api.eCommerce/Api.eCommerce/Controllers/InventoryController.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
using Library.eCommerce.DTO;
using Library.eCommerce.Models;
using Microsoft.AspNetCore.Mvc;
using Spring2025_Samples.Models;

namespace Api.eCommerce.Controllers
{
[ApiController]
[Route("[controller]")]
public class InventoryController : ControllerBase
{

private readonly ILogger<InventoryController> _logger;

public InventoryController(ILogger<InventoryController> logger)
{
_logger = logger;
}

[HttpGet]
public IEnumerable<Item?> Get()
{
return new List<Item?>
{
new Item{ Product = new ProductDTO{Id = 1, Name ="Product 1"}, Id = 1, Quantity = 1 },
new Item{ Product = new ProductDTO{Id = 2, Name ="Product 2"}, Id = 2 , Quantity = 2 },
new Item{ Product = new ProductDTO{Id = 3, Name ="Product 3"}, Id=3 , Quantity = 3 }
};
}
}
}
25 changes: 25 additions & 0 deletions Api.eCommerce/Api.eCommerce/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
var builder = WebApplication.CreateBuilder(args);

// Add services to the container.

builder.Services.AddControllers();
// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
builder.Services.AddEndpointsApiExplorer();
builder.Services.AddSwaggerGen();

var app = builder.Build();

// Configure the HTTP request pipeline.
if (app.Environment.IsDevelopment())
{
app.UseSwagger();
app.UseSwaggerUI();
}

app.UseHttpsRedirection();

app.UseAuthorization();

app.MapControllers();

app.Run();
41 changes: 41 additions & 0 deletions Api.eCommerce/Api.eCommerce/Properties/launchSettings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
{
"$schema": "http://json.schemastore.org/launchsettings.json",
"iisSettings": {
"windowsAuthentication": false,
"anonymousAuthentication": true,
"iisExpress": {
"applicationUrl": "http://localhost:48399",
"sslPort": 44355
}
},
"profiles": {
"http": {
"commandName": "Project",
"dotnetRunMessages": true,
"launchBrowser": true,
"launchUrl": "swagger",
"applicationUrl": "http://localhost:5149",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"https": {
"commandName": "Project",
"dotnetRunMessages": true,
"launchBrowser": true,
"launchUrl": "swagger",
"applicationUrl": "https://localhost:7009;http://localhost:5149",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"IIS Express": {
"commandName": "IISExpress",
"launchBrowser": true,
"launchUrl": "swagger",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
}
}
}
13 changes: 13 additions & 0 deletions Api.eCommerce/Api.eCommerce/WeatherForecast.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
namespace Api.eCommerce
{
public class WeatherForecast
{
public DateOnly Date { get; set; }

public int TemperatureC { get; set; }

public int TemperatureF => 32 + (int)(TemperatureC / 0.5556);

public string? Summary { get; set; }
}
}
8 changes: 8 additions & 0 deletions Api.eCommerce/Api.eCommerce/appsettings.Development.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
}
}
9 changes: 9 additions & 0 deletions Api.eCommerce/Api.eCommerce/appsettings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
},
"AllowedHosts": "*"
}
48 changes: 48 additions & 0 deletions Library.eCommerce/DTO/ProductDTO.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
using Spring2025_Samples.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Library.eCommerce.DTO
{
public class ProductDTO
{
public int Id { get; set; }

public string? Name { get; set; }

public string? Display
{
get
{
return $"{Id}. {Name}";
}
}



public ProductDTO()
{
Name = string.Empty;
}

public ProductDTO(Product p)
{
Name = p.Name;
Id = p.Id;
}

public ProductDTO(ProductDTO p)
{
Name = p.Name;
Id = p.Id;
}

public override string ToString()
{
return Display ?? string.Empty;
}
}
}
4 changes: 4 additions & 0 deletions Library.eCommerce/Library.eCommerce.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,8 @@
<Nullable>enable</Nullable>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Maui.Controls" Version="8.0.7" />
</ItemGroup>

</Project>
73 changes: 73 additions & 0 deletions Library.eCommerce/Models/Item.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
using Library.eCommerce.DTO;
using Library.eCommerce.Services;
using Spring2025_Samples.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Input;

namespace Library.eCommerce.Models
{
public class Item
{
public int Id { get; set; }
public ProductDTO Product { get; set; }
public int? Quantity { get; set; }

public int Price { get; set; }



public override string ToString()
{
return $"{Product} Quantity:{Quantity}";
}

public string Display {
get
{
return $"{Product?.Display ?? string.Empty} x{Quantity} ${Price}";
}
}

public int AddCertainAmount(int amount)
{
for(int i = 0; i < amount; i++)
{
if (ShoppingCartService.Current.AddOrUpdate(this) == null)
{
return 0;
}
}
return 1;
}

public Item()
{
Product = new ProductDTO();
Quantity = 0;


}

public void DoAdd()
{
ShoppingCartService.Current.AddOrUpdate(this);
}



public Item(Item i)
{
Product = new ProductDTO(i.Product);
Quantity = i.Quantity;
Id = i.Id;
Price = i.Price;

}


}
}
23 changes: 22 additions & 1 deletion Library.eCommerce/Models/Product.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
using Library.eCommerce.DTO;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
Expand All @@ -20,14 +21,34 @@ public string? Display
}
}

public string LegacyProperty1 { get; set; }
public string LegacyProperty2 { get; set; }
public string LegacyProperty3 { get; set; }
public string LegacyProperty4 { get; set; }
public string LegacyProperty5 { get; set; }
public string LegacyProperty6 { get; set; }

public Product()
{
Name = string.Empty;
}

public Product(Product p)
{
Name = p.Name;
Id = p.Id;
}

public override string ToString()
{
return Display ?? string.Empty;
}

public Product(ProductDTO p)
{
Name = p.Name;
Id = p.Id;
LegacyProperty1 = string.Empty;
}
}
}
23 changes: 23 additions & 0 deletions Library.eCommerce/Models/ShoppingCart.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Library.eCommerce.Services;

namespace Library.eCommerce.Models
{
public class ShoppingCart
{
public int Id { get; set; }

public ShoppingCartService? ShopService { get; set; }

public ShoppingCart(int newId, ShoppingCartService svc)
{
Id = newId;
ShopService = svc;
}

}
}
Loading