Init
This commit is contained in:
commit
da8f1f8ba3
12
Controllers/CommentController.cs
Normal file
12
Controllers/CommentController.cs
Normal file
@ -0,0 +1,12 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace api.Controllers
|
||||
{
|
||||
public class CommentController
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
96
Controllers/StockController.cs
Normal file
96
Controllers/StockController.cs
Normal file
@ -0,0 +1,96 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Threading.Tasks;
|
||||
using api.Data;
|
||||
using api.Dtos.Stock;
|
||||
using api.Interfaces;
|
||||
using api.Mappers;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace api.Controllers
|
||||
{
|
||||
[Route("api/stock")]
|
||||
[ApiController]
|
||||
public class StockController : ControllerBase
|
||||
{
|
||||
private readonly IStockRepository _stockRepo;
|
||||
private readonly ApplicationDbContext _context;
|
||||
public StockController(ApplicationDbContext context, IStockRepository stockRepo)
|
||||
{
|
||||
_stockRepo = stockRepo;
|
||||
_context = context;
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public async Task<IActionResult> GetAll()
|
||||
{
|
||||
var stocks = await _stockRepo.GetAllAsync();
|
||||
var stockDto = stocks.Select(s => s.ToStockDto()).ToList();
|
||||
return Ok(stockDto);
|
||||
}
|
||||
|
||||
[HttpGet("{id}")]
|
||||
public async Task<IActionResult> GetById([FromRoute] int id)
|
||||
{
|
||||
var stock = await _context.Stocks.FindAsync(id);
|
||||
if (stock == null)
|
||||
{
|
||||
return NotFound();
|
||||
}
|
||||
return Ok(stock.ToStockDto());
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public async Task<IActionResult> Create([FromBody] CreateStockRequestDto stockDto)
|
||||
{
|
||||
var stockModel = stockDto.ToStockModel();
|
||||
await _context.Stocks.AddAsync(stockModel);
|
||||
await _context.SaveChangesAsync();
|
||||
return CreatedAtAction(nameof(GetById), new { id = stockModel.Id }, stockModel.ToStockDto());
|
||||
}
|
||||
|
||||
|
||||
[HttpPut]
|
||||
[Route("{id}")]
|
||||
|
||||
public async Task<IActionResult> Update([FromRoute] int id, [FromBody] UpdateStockRequestDto updateDto)
|
||||
{
|
||||
var stockModel = await _context.Stocks.FirstOrDefaultAsync(x => x.Id == id);
|
||||
|
||||
if (stockModel == null)
|
||||
{
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
stockModel.Symbol = updateDto.Symbol;
|
||||
stockModel.CompanyName = updateDto.CompanyName;
|
||||
stockModel.Purchase = updateDto.Purchase;
|
||||
stockModel.LastDiv = updateDto.LastDiv;
|
||||
stockModel.Industry = updateDto.Industry;
|
||||
stockModel.MarketCap = updateDto.MarketCap;
|
||||
|
||||
await _context.SaveChangesAsync();
|
||||
return Ok(stockModel.ToStockDto());
|
||||
}
|
||||
|
||||
[HttpDelete]
|
||||
[Route("{id}")]
|
||||
public async Task<IActionResult> Delete([FromRoute] int id)
|
||||
{
|
||||
var stockModel = await _context.Stocks.FirstOrDefaultAsync(x => x.Id == id);
|
||||
|
||||
if (stockModel == null)
|
||||
{
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
_context.Stocks.Remove(stockModel);
|
||||
await _context.SaveChangesAsync();
|
||||
return NoContent();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
21
Data/ApplicationDbContext.cs
Normal file
21
Data/ApplicationDbContext.cs
Normal file
@ -0,0 +1,21 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using api.Models;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace api.Data
|
||||
{
|
||||
public class ApplicationDbContext : DbContext
|
||||
{
|
||||
public ApplicationDbContext(DbContextOptions dbContextOptions) : base(dbContextOptions)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
public DbSet<Stock> Stocks { get; set; }
|
||||
public DbSet<Comment> Comments { get; set; }
|
||||
}
|
||||
}
|
||||
23
Dtos/Stock/CreateStockRequestDto.cs
Normal file
23
Dtos/Stock/CreateStockRequestDto.cs
Normal file
@ -0,0 +1,23 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace api.Dtos.Stock
|
||||
{
|
||||
public class CreateStockRequestDto
|
||||
{
|
||||
|
||||
public string Symbol { get; set; } = string.Empty;
|
||||
public string CompanyName { get; set; } = string.Empty;
|
||||
|
||||
public decimal Purchase { get; set; }
|
||||
|
||||
public decimal LastDiv { get; set; }
|
||||
|
||||
public string Industry { get; set; } = string.Empty;
|
||||
|
||||
public long MarketCap { get; set; }
|
||||
|
||||
}
|
||||
}
|
||||
25
Dtos/Stock/StockDto.cs
Normal file
25
Dtos/Stock/StockDto.cs
Normal file
@ -0,0 +1,25 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace api.Dtos.Stock
|
||||
{
|
||||
public class StockDto
|
||||
{
|
||||
public int Id { get; set; }
|
||||
|
||||
public string Symbol { get; set; } = string.Empty;
|
||||
public string CompanyName { get; set; } = string.Empty;
|
||||
|
||||
public decimal Purchase { get; set; }
|
||||
|
||||
public decimal LastDiv { get; set; }
|
||||
|
||||
public string Industry { get; set; } = string.Empty;
|
||||
|
||||
public long MarketCap { get; set; }
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
21
Dtos/Stock/UpdateStockRequestDto.cs
Normal file
21
Dtos/Stock/UpdateStockRequestDto.cs
Normal file
@ -0,0 +1,21 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace api.Dtos.Stock
|
||||
{
|
||||
public class UpdateStockRequestDto
|
||||
{
|
||||
public string Symbol { get; set; } = string.Empty;
|
||||
public string CompanyName { get; set; } = string.Empty;
|
||||
|
||||
public decimal Purchase { get; set; }
|
||||
|
||||
public decimal LastDiv { get; set; }
|
||||
|
||||
public string Industry { get; set; } = string.Empty;
|
||||
|
||||
public long MarketCap { get; set; }
|
||||
}
|
||||
}
|
||||
13
Interfaces/IStockRepository.cs
Normal file
13
Interfaces/IStockRepository.cs
Normal file
@ -0,0 +1,13 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using api.Models;
|
||||
|
||||
namespace api.Interfaces
|
||||
{
|
||||
public interface IStockRepository
|
||||
{
|
||||
Task<List<Stock>> GetAllAsync();
|
||||
}
|
||||
}
|
||||
43
Mappers/StockMappers.cs
Normal file
43
Mappers/StockMappers.cs
Normal file
@ -0,0 +1,43 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using api.Dtos.Stock;
|
||||
using api.Models;
|
||||
using Microsoft.CodeAnalysis.CSharp.Syntax;
|
||||
|
||||
namespace api.Mappers
|
||||
{
|
||||
public static class StockMappers
|
||||
{
|
||||
public static StockDto ToStockDto(this Stock stockModel)
|
||||
{
|
||||
return new StockDto
|
||||
{
|
||||
Id = stockModel.Id,
|
||||
Symbol = stockModel.Symbol,
|
||||
CompanyName = stockModel.CompanyName,
|
||||
Purchase = stockModel.Purchase,
|
||||
LastDiv = stockModel.LastDiv,
|
||||
Industry = stockModel.Industry,
|
||||
MarketCap = stockModel.MarketCap
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
public static Stock ToStockModel(this CreateStockRequestDto stockDto)
|
||||
{
|
||||
return new Stock
|
||||
{
|
||||
Symbol = stockDto.Symbol,
|
||||
CompanyName = stockDto.CompanyName,
|
||||
Purchase = stockDto.Purchase,
|
||||
LastDiv = stockDto.LastDiv,
|
||||
Industry = stockDto.Industry,
|
||||
MarketCap = stockDto.MarketCap
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
107
Migrations/20250925120417_init.Designer.cs
generated
Normal file
107
Migrations/20250925120417_init.Designer.cs
generated
Normal file
@ -0,0 +1,107 @@
|
||||
// <auto-generated />
|
||||
using System;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||
using Microsoft.EntityFrameworkCore.Metadata;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||
using api.Data;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace api.Migrations
|
||||
{
|
||||
[DbContext(typeof(ApplicationDbContext))]
|
||||
[Migration("20250925120417_init")]
|
||||
partial class init
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
||||
{
|
||||
#pragma warning disable 612, 618
|
||||
modelBuilder
|
||||
.HasAnnotation("ProductVersion", "9.0.9")
|
||||
.HasAnnotation("Relational:MaxIdentifierLength", 128);
|
||||
|
||||
SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder);
|
||||
|
||||
modelBuilder.Entity("api.Models.Comment", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<string>("Content")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<DateTime>("CreatedOn")
|
||||
.HasColumnType("datetime2");
|
||||
|
||||
b.Property<int?>("StockId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<string>("Title")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("StockId");
|
||||
|
||||
b.ToTable("Comments");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("api.Models.Stock", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<string>("CompanyName")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("Industry")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<decimal>("LastDiv")
|
||||
.HasColumnType("decimal(18,2)");
|
||||
|
||||
b.Property<long>("MarketCap")
|
||||
.HasColumnType("bigint");
|
||||
|
||||
b.Property<decimal>("Purchase")
|
||||
.HasColumnType("decimal(18,2)");
|
||||
|
||||
b.Property<string>("Symbol")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Stocks");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("api.Models.Comment", b =>
|
||||
{
|
||||
b.HasOne("api.Models.Stock", "Stock")
|
||||
.WithMany("Comments")
|
||||
.HasForeignKey("StockId");
|
||||
|
||||
b.Navigation("Stock");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("api.Models.Stock", b =>
|
||||
{
|
||||
b.Navigation("Comments");
|
||||
});
|
||||
#pragma warning restore 612, 618
|
||||
}
|
||||
}
|
||||
}
|
||||
69
Migrations/20250925120417_init.cs
Normal file
69
Migrations/20250925120417_init.cs
Normal file
@ -0,0 +1,69 @@
|
||||
using System;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace api.Migrations
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public partial class init : Migration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.CreateTable(
|
||||
name: "Stocks",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "int", nullable: false)
|
||||
.Annotation("SqlServer:Identity", "1, 1"),
|
||||
Symbol = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
||||
CompanyName = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
||||
Purchase = table.Column<decimal>(type: "decimal(18,2)", nullable: false),
|
||||
LastDiv = table.Column<decimal>(type: "decimal(18,2)", nullable: false),
|
||||
Industry = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
||||
MarketCap = table.Column<long>(type: "bigint", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_Stocks", x => x.Id);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "Comments",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "int", nullable: false)
|
||||
.Annotation("SqlServer:Identity", "1, 1"),
|
||||
Title = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
||||
Content = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
||||
CreatedOn = table.Column<DateTime>(type: "datetime2", nullable: false),
|
||||
StockId = table.Column<int>(type: "int", nullable: true)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_Comments", x => x.Id);
|
||||
table.ForeignKey(
|
||||
name: "FK_Comments_Stocks_StockId",
|
||||
column: x => x.StockId,
|
||||
principalTable: "Stocks",
|
||||
principalColumn: "Id");
|
||||
});
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_Comments_StockId",
|
||||
table: "Comments",
|
||||
column: "StockId");
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropTable(
|
||||
name: "Comments");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "Stocks");
|
||||
}
|
||||
}
|
||||
}
|
||||
104
Migrations/ApplicationDbContextModelSnapshot.cs
Normal file
104
Migrations/ApplicationDbContextModelSnapshot.cs
Normal file
@ -0,0 +1,104 @@
|
||||
// <auto-generated />
|
||||
using System;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||
using Microsoft.EntityFrameworkCore.Metadata;
|
||||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||
using api.Data;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace api.Migrations
|
||||
{
|
||||
[DbContext(typeof(ApplicationDbContext))]
|
||||
partial class ApplicationDbContextModelSnapshot : ModelSnapshot
|
||||
{
|
||||
protected override void BuildModel(ModelBuilder modelBuilder)
|
||||
{
|
||||
#pragma warning disable 612, 618
|
||||
modelBuilder
|
||||
.HasAnnotation("ProductVersion", "9.0.9")
|
||||
.HasAnnotation("Relational:MaxIdentifierLength", 128);
|
||||
|
||||
SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder);
|
||||
|
||||
modelBuilder.Entity("api.Models.Comment", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<string>("Content")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<DateTime>("CreatedOn")
|
||||
.HasColumnType("datetime2");
|
||||
|
||||
b.Property<int?>("StockId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<string>("Title")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("StockId");
|
||||
|
||||
b.ToTable("Comments");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("api.Models.Stock", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<string>("CompanyName")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("Industry")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<decimal>("LastDiv")
|
||||
.HasColumnType("decimal(18,2)");
|
||||
|
||||
b.Property<long>("MarketCap")
|
||||
.HasColumnType("bigint");
|
||||
|
||||
b.Property<decimal>("Purchase")
|
||||
.HasColumnType("decimal(18,2)");
|
||||
|
||||
b.Property<string>("Symbol")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Stocks");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("api.Models.Comment", b =>
|
||||
{
|
||||
b.HasOne("api.Models.Stock", "Stock")
|
||||
.WithMany("Comments")
|
||||
.HasForeignKey("StockId");
|
||||
|
||||
b.Navigation("Stock");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("api.Models.Stock", b =>
|
||||
{
|
||||
b.Navigation("Comments");
|
||||
});
|
||||
#pragma warning restore 612, 618
|
||||
}
|
||||
}
|
||||
}
|
||||
19
Models/Comment.cs
Normal file
19
Models/Comment.cs
Normal file
@ -0,0 +1,19 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace api.Models
|
||||
{
|
||||
public class Comment
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public string Title { get; set; } = string.Empty;
|
||||
public string Content { get; set; } = string.Empty;
|
||||
public DateTime CreatedOn { get; set; }
|
||||
public int? StockId { get; set; }
|
||||
//Navigation property
|
||||
public Stock? Stock { get; set; }
|
||||
|
||||
}
|
||||
}
|
||||
31
Models/Stock.cs
Normal file
31
Models/Stock.cs
Normal file
@ -0,0 +1,31 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using System.Linq;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.Intrinsics.X86;
|
||||
using System.Threading.Tasks;
|
||||
using System.Xml;
|
||||
|
||||
namespace api.Models
|
||||
{
|
||||
public class Stock
|
||||
{
|
||||
public int Id { get; set; }
|
||||
|
||||
public string Symbol { get; set; } = string.Empty;
|
||||
public string CompanyName { get; set; } = string.Empty;
|
||||
|
||||
[Column(TypeName = "decimal(18,2)")]
|
||||
public decimal Purchase { get; set; }
|
||||
|
||||
[Column(TypeName = "decimal(18,2)")]
|
||||
public decimal LastDiv { get; set; }
|
||||
|
||||
public string Industry { get; set; } = string.Empty;
|
||||
|
||||
public long MarketCap { get; set; }
|
||||
|
||||
public List<Comment> Comments { get; set; } = new List<Comment>();
|
||||
}
|
||||
}
|
||||
36
Program.cs
Normal file
36
Program.cs
Normal file
@ -0,0 +1,36 @@
|
||||
using api.Data;
|
||||
using api.Interfaces;
|
||||
using api.Repository;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
var builder = WebApplication.CreateBuilder(args);
|
||||
|
||||
builder.Services.AddControllers();
|
||||
builder.Services.AddEndpointsApiExplorer();
|
||||
builder.Services.AddSwaggerGen();
|
||||
|
||||
|
||||
builder.Services.AddDbContext<ApplicationDbContext>(options =>
|
||||
{
|
||||
options.UseSqlServer(builder.Configuration.GetConnectionString("DefaultConnection"));
|
||||
});
|
||||
|
||||
builder.Services.AddScoped<IStockRepository, StockRepository>();
|
||||
|
||||
|
||||
|
||||
var app = builder.Build();
|
||||
|
||||
|
||||
if (app.Environment.IsDevelopment())
|
||||
{
|
||||
app.UseSwagger();
|
||||
app.UseSwaggerUI();
|
||||
}
|
||||
|
||||
app.UseHttpsRedirection();
|
||||
|
||||
app.MapControllers();
|
||||
|
||||
app.Run();
|
||||
|
||||
23
Properties/launchSettings.json
Normal file
23
Properties/launchSettings.json
Normal file
@ -0,0 +1,23 @@
|
||||
{
|
||||
"$schema": "https://json.schemastore.org/launchsettings.json",
|
||||
"profiles": {
|
||||
"http": {
|
||||
"commandName": "Project",
|
||||
"dotnetRunMessages": true,
|
||||
"launchBrowser": false,
|
||||
"applicationUrl": "http://localhost:5128",
|
||||
"environmentVariables": {
|
||||
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||
}
|
||||
},
|
||||
"https": {
|
||||
"commandName": "Project",
|
||||
"dotnetRunMessages": true,
|
||||
"launchBrowser": false,
|
||||
"applicationUrl": "https://localhost:7250;http://localhost:5128",
|
||||
"environmentVariables": {
|
||||
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
24
Repository/StockRepository.cs
Normal file
24
Repository/StockRepository.cs
Normal file
@ -0,0 +1,24 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using api.Data;
|
||||
using api.Interfaces;
|
||||
using api.Models;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace api.Repository
|
||||
{
|
||||
public class StockRepository : IStockRepository
|
||||
{
|
||||
private readonly ApplicationDbContext _context;
|
||||
public StockRepository(ApplicationDbContext context)
|
||||
{
|
||||
_context = context;
|
||||
}
|
||||
public Task<List<Stock>> GetAllAsync()
|
||||
{
|
||||
return _context.Stocks.ToListAsync();
|
||||
}
|
||||
}
|
||||
}
|
||||
17
api.csproj
Normal file
17
api.csproj
Normal file
@ -0,0 +1,17 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk.Web">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net9.0</TargetFramework>
|
||||
<Nullable>enable</Nullable>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.AspNetCore.OpenApi" Version="9.0.8" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="9.0.9" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="9.0.9" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="9.0.9" />
|
||||
<PackageReference Include="Swashbuckle.AspNetCore" Version="9.0.4" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
6
api.http
Normal file
6
api.http
Normal file
@ -0,0 +1,6 @@
|
||||
@api_HostAddress = http://localhost:5128
|
||||
|
||||
GET {{api_HostAddress}}/weatherforecast/
|
||||
Accept: application/json
|
||||
|
||||
###
|
||||
11
appsettings.Development.json
Normal file
11
appsettings.Development.json
Normal file
@ -0,0 +1,11 @@
|
||||
{
|
||||
"ConnectionStrings": {
|
||||
"DefaultConnection": "Server=(localdb)\\mssqllocaldb;Database=finshark;Trusted_Connection=True;MultipleActiveResultSets=true"
|
||||
},
|
||||
"Logging": {
|
||||
"LogLevel": {
|
||||
"Default": "Information",
|
||||
"Microsoft.AspNetCore": "Warning"
|
||||
}
|
||||
}
|
||||
}
|
||||
9
appsettings.json
Normal file
9
appsettings.json
Normal file
@ -0,0 +1,9 @@
|
||||
{
|
||||
"Logging": {
|
||||
"LogLevel": {
|
||||
"Default": "Information",
|
||||
"Microsoft.AspNetCore": "Warning"
|
||||
}
|
||||
},
|
||||
"AllowedHosts": "*"
|
||||
}
|
||||
BIN
bin/Debug/net9.0/Azure.Core.dll
Normal file
BIN
bin/Debug/net9.0/Azure.Core.dll
Normal file
Binary file not shown.
BIN
bin/Debug/net9.0/Azure.Identity.dll
Normal file
BIN
bin/Debug/net9.0/Azure.Identity.dll
Normal file
Binary file not shown.
BIN
bin/Debug/net9.0/Humanizer.dll
Normal file
BIN
bin/Debug/net9.0/Humanizer.dll
Normal file
Binary file not shown.
BIN
bin/Debug/net9.0/Microsoft.AspNetCore.OpenApi.dll
Normal file
BIN
bin/Debug/net9.0/Microsoft.AspNetCore.OpenApi.dll
Normal file
Binary file not shown.
BIN
bin/Debug/net9.0/Microsoft.Bcl.AsyncInterfaces.dll
Normal file
BIN
bin/Debug/net9.0/Microsoft.Bcl.AsyncInterfaces.dll
Normal file
Binary file not shown.
BIN
bin/Debug/net9.0/Microsoft.Build.Locator.dll
Normal file
BIN
bin/Debug/net9.0/Microsoft.Build.Locator.dll
Normal file
Binary file not shown.
BIN
bin/Debug/net9.0/Microsoft.CodeAnalysis.CSharp.Workspaces.dll
Normal file
BIN
bin/Debug/net9.0/Microsoft.CodeAnalysis.CSharp.Workspaces.dll
Normal file
Binary file not shown.
BIN
bin/Debug/net9.0/Microsoft.CodeAnalysis.CSharp.dll
Normal file
BIN
bin/Debug/net9.0/Microsoft.CodeAnalysis.CSharp.dll
Normal file
Binary file not shown.
Binary file not shown.
BIN
bin/Debug/net9.0/Microsoft.CodeAnalysis.Workspaces.MSBuild.dll
Normal file
BIN
bin/Debug/net9.0/Microsoft.CodeAnalysis.Workspaces.MSBuild.dll
Normal file
Binary file not shown.
BIN
bin/Debug/net9.0/Microsoft.CodeAnalysis.Workspaces.dll
Normal file
BIN
bin/Debug/net9.0/Microsoft.CodeAnalysis.Workspaces.dll
Normal file
Binary file not shown.
BIN
bin/Debug/net9.0/Microsoft.CodeAnalysis.dll
Normal file
BIN
bin/Debug/net9.0/Microsoft.CodeAnalysis.dll
Normal file
Binary file not shown.
BIN
bin/Debug/net9.0/Microsoft.Data.SqlClient.dll
Normal file
BIN
bin/Debug/net9.0/Microsoft.Data.SqlClient.dll
Normal file
Binary file not shown.
BIN
bin/Debug/net9.0/Microsoft.EntityFrameworkCore.Abstractions.dll
Normal file
BIN
bin/Debug/net9.0/Microsoft.EntityFrameworkCore.Abstractions.dll
Normal file
Binary file not shown.
BIN
bin/Debug/net9.0/Microsoft.EntityFrameworkCore.Design.dll
Normal file
BIN
bin/Debug/net9.0/Microsoft.EntityFrameworkCore.Design.dll
Normal file
Binary file not shown.
BIN
bin/Debug/net9.0/Microsoft.EntityFrameworkCore.Relational.dll
Normal file
BIN
bin/Debug/net9.0/Microsoft.EntityFrameworkCore.Relational.dll
Normal file
Binary file not shown.
BIN
bin/Debug/net9.0/Microsoft.EntityFrameworkCore.SqlServer.dll
Normal file
BIN
bin/Debug/net9.0/Microsoft.EntityFrameworkCore.SqlServer.dll
Normal file
Binary file not shown.
BIN
bin/Debug/net9.0/Microsoft.EntityFrameworkCore.dll
Normal file
BIN
bin/Debug/net9.0/Microsoft.EntityFrameworkCore.dll
Normal file
Binary file not shown.
BIN
bin/Debug/net9.0/Microsoft.Extensions.Caching.Abstractions.dll
Normal file
BIN
bin/Debug/net9.0/Microsoft.Extensions.Caching.Abstractions.dll
Normal file
Binary file not shown.
BIN
bin/Debug/net9.0/Microsoft.Extensions.Caching.Memory.dll
Normal file
BIN
bin/Debug/net9.0/Microsoft.Extensions.Caching.Memory.dll
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
bin/Debug/net9.0/Microsoft.Extensions.DependencyInjection.dll
Normal file
BIN
bin/Debug/net9.0/Microsoft.Extensions.DependencyInjection.dll
Normal file
Binary file not shown.
BIN
bin/Debug/net9.0/Microsoft.Extensions.DependencyModel.dll
Normal file
BIN
bin/Debug/net9.0/Microsoft.Extensions.DependencyModel.dll
Normal file
Binary file not shown.
BIN
bin/Debug/net9.0/Microsoft.Extensions.Logging.Abstractions.dll
Normal file
BIN
bin/Debug/net9.0/Microsoft.Extensions.Logging.Abstractions.dll
Normal file
Binary file not shown.
BIN
bin/Debug/net9.0/Microsoft.Extensions.Logging.dll
Normal file
BIN
bin/Debug/net9.0/Microsoft.Extensions.Logging.dll
Normal file
Binary file not shown.
BIN
bin/Debug/net9.0/Microsoft.Extensions.Options.dll
Normal file
BIN
bin/Debug/net9.0/Microsoft.Extensions.Options.dll
Normal file
Binary file not shown.
BIN
bin/Debug/net9.0/Microsoft.Extensions.Primitives.dll
Normal file
BIN
bin/Debug/net9.0/Microsoft.Extensions.Primitives.dll
Normal file
Binary file not shown.
BIN
bin/Debug/net9.0/Microsoft.Identity.Client.Extensions.Msal.dll
Normal file
BIN
bin/Debug/net9.0/Microsoft.Identity.Client.Extensions.Msal.dll
Normal file
Binary file not shown.
BIN
bin/Debug/net9.0/Microsoft.Identity.Client.dll
Normal file
BIN
bin/Debug/net9.0/Microsoft.Identity.Client.dll
Normal file
Binary file not shown.
BIN
bin/Debug/net9.0/Microsoft.IdentityModel.Abstractions.dll
Normal file
BIN
bin/Debug/net9.0/Microsoft.IdentityModel.Abstractions.dll
Normal file
Binary file not shown.
BIN
bin/Debug/net9.0/Microsoft.IdentityModel.JsonWebTokens.dll
Normal file
BIN
bin/Debug/net9.0/Microsoft.IdentityModel.JsonWebTokens.dll
Normal file
Binary file not shown.
BIN
bin/Debug/net9.0/Microsoft.IdentityModel.Logging.dll
Normal file
BIN
bin/Debug/net9.0/Microsoft.IdentityModel.Logging.dll
Normal file
Binary file not shown.
Binary file not shown.
BIN
bin/Debug/net9.0/Microsoft.IdentityModel.Protocols.dll
Normal file
BIN
bin/Debug/net9.0/Microsoft.IdentityModel.Protocols.dll
Normal file
Binary file not shown.
BIN
bin/Debug/net9.0/Microsoft.IdentityModel.Tokens.dll
Normal file
BIN
bin/Debug/net9.0/Microsoft.IdentityModel.Tokens.dll
Normal file
Binary file not shown.
BIN
bin/Debug/net9.0/Microsoft.OpenApi.dll
Normal file
BIN
bin/Debug/net9.0/Microsoft.OpenApi.dll
Normal file
Binary file not shown.
BIN
bin/Debug/net9.0/Microsoft.SqlServer.Server.dll
Normal file
BIN
bin/Debug/net9.0/Microsoft.SqlServer.Server.dll
Normal file
Binary file not shown.
BIN
bin/Debug/net9.0/Microsoft.Win32.SystemEvents.dll
Normal file
BIN
bin/Debug/net9.0/Microsoft.Win32.SystemEvents.dll
Normal file
Binary file not shown.
BIN
bin/Debug/net9.0/Mono.TextTemplating.dll
Normal file
BIN
bin/Debug/net9.0/Mono.TextTemplating.dll
Normal file
Binary file not shown.
BIN
bin/Debug/net9.0/Swashbuckle.AspNetCore.Swagger.dll
Normal file
BIN
bin/Debug/net9.0/Swashbuckle.AspNetCore.Swagger.dll
Normal file
Binary file not shown.
BIN
bin/Debug/net9.0/Swashbuckle.AspNetCore.SwaggerGen.dll
Normal file
BIN
bin/Debug/net9.0/Swashbuckle.AspNetCore.SwaggerGen.dll
Normal file
Binary file not shown.
BIN
bin/Debug/net9.0/Swashbuckle.AspNetCore.SwaggerUI.dll
Normal file
BIN
bin/Debug/net9.0/Swashbuckle.AspNetCore.SwaggerUI.dll
Normal file
Binary file not shown.
BIN
bin/Debug/net9.0/System.ClientModel.dll
Normal file
BIN
bin/Debug/net9.0/System.ClientModel.dll
Normal file
Binary file not shown.
BIN
bin/Debug/net9.0/System.CodeDom.dll
Normal file
BIN
bin/Debug/net9.0/System.CodeDom.dll
Normal file
Binary file not shown.
BIN
bin/Debug/net9.0/System.Composition.AttributedModel.dll
Normal file
BIN
bin/Debug/net9.0/System.Composition.AttributedModel.dll
Normal file
Binary file not shown.
BIN
bin/Debug/net9.0/System.Composition.Convention.dll
Normal file
BIN
bin/Debug/net9.0/System.Composition.Convention.dll
Normal file
Binary file not shown.
BIN
bin/Debug/net9.0/System.Composition.Hosting.dll
Normal file
BIN
bin/Debug/net9.0/System.Composition.Hosting.dll
Normal file
Binary file not shown.
BIN
bin/Debug/net9.0/System.Composition.Runtime.dll
Normal file
BIN
bin/Debug/net9.0/System.Composition.Runtime.dll
Normal file
Binary file not shown.
BIN
bin/Debug/net9.0/System.Composition.TypedParts.dll
Normal file
BIN
bin/Debug/net9.0/System.Composition.TypedParts.dll
Normal file
Binary file not shown.
BIN
bin/Debug/net9.0/System.Configuration.ConfigurationManager.dll
Normal file
BIN
bin/Debug/net9.0/System.Configuration.ConfigurationManager.dll
Normal file
Binary file not shown.
BIN
bin/Debug/net9.0/System.Drawing.Common.dll
Normal file
BIN
bin/Debug/net9.0/System.Drawing.Common.dll
Normal file
Binary file not shown.
BIN
bin/Debug/net9.0/System.Formats.Asn1.dll
Normal file
BIN
bin/Debug/net9.0/System.Formats.Asn1.dll
Normal file
Binary file not shown.
BIN
bin/Debug/net9.0/System.IdentityModel.Tokens.Jwt.dll
Normal file
BIN
bin/Debug/net9.0/System.IdentityModel.Tokens.Jwt.dll
Normal file
Binary file not shown.
BIN
bin/Debug/net9.0/System.Memory.Data.dll
Normal file
BIN
bin/Debug/net9.0/System.Memory.Data.dll
Normal file
Binary file not shown.
BIN
bin/Debug/net9.0/System.Runtime.Caching.dll
Normal file
BIN
bin/Debug/net9.0/System.Runtime.Caching.dll
Normal file
Binary file not shown.
BIN
bin/Debug/net9.0/System.Security.Cryptography.ProtectedData.dll
Normal file
BIN
bin/Debug/net9.0/System.Security.Cryptography.ProtectedData.dll
Normal file
Binary file not shown.
BIN
bin/Debug/net9.0/System.Security.Permissions.dll
Normal file
BIN
bin/Debug/net9.0/System.Security.Permissions.dll
Normal file
Binary file not shown.
BIN
bin/Debug/net9.0/System.Text.Json.dll
Normal file
BIN
bin/Debug/net9.0/System.Text.Json.dll
Normal file
Binary file not shown.
BIN
bin/Debug/net9.0/System.Windows.Extensions.dll
Normal file
BIN
bin/Debug/net9.0/System.Windows.Extensions.dll
Normal file
Binary file not shown.
1682
bin/Debug/net9.0/api.deps.json
Normal file
1682
bin/Debug/net9.0/api.deps.json
Normal file
File diff suppressed because it is too large
Load Diff
BIN
bin/Debug/net9.0/api.dll
Normal file
BIN
bin/Debug/net9.0/api.dll
Normal file
Binary file not shown.
BIN
bin/Debug/net9.0/api.exe
Normal file
BIN
bin/Debug/net9.0/api.exe
Normal file
Binary file not shown.
BIN
bin/Debug/net9.0/api.pdb
Normal file
BIN
bin/Debug/net9.0/api.pdb
Normal file
Binary file not shown.
20
bin/Debug/net9.0/api.runtimeconfig.json
Normal file
20
bin/Debug/net9.0/api.runtimeconfig.json
Normal file
@ -0,0 +1,20 @@
|
||||
{
|
||||
"runtimeOptions": {
|
||||
"tfm": "net9.0",
|
||||
"frameworks": [
|
||||
{
|
||||
"name": "Microsoft.NETCore.App",
|
||||
"version": "9.0.0"
|
||||
},
|
||||
{
|
||||
"name": "Microsoft.AspNetCore.App",
|
||||
"version": "9.0.0"
|
||||
}
|
||||
],
|
||||
"configProperties": {
|
||||
"System.GC.Server": true,
|
||||
"System.Reflection.NullabilityInfoContext.IsSupported": true,
|
||||
"System.Runtime.Serialization.EnableUnsafeBinaryFormatterSerialization": false
|
||||
}
|
||||
}
|
||||
}
|
||||
1
bin/Debug/net9.0/api.staticwebassets.endpoints.json
Normal file
1
bin/Debug/net9.0/api.staticwebassets.endpoints.json
Normal file
@ -0,0 +1 @@
|
||||
{"Version":1,"ManifestType":"Build","Endpoints":[]}
|
||||
11
bin/Debug/net9.0/appsettings.Development.json
Normal file
11
bin/Debug/net9.0/appsettings.Development.json
Normal file
@ -0,0 +1,11 @@
|
||||
{
|
||||
"ConnectionStrings": {
|
||||
"DefaultConnection": "Server=(localdb)\\mssqllocaldb;Database=finshark;Trusted_Connection=True;MultipleActiveResultSets=true"
|
||||
},
|
||||
"Logging": {
|
||||
"LogLevel": {
|
||||
"Default": "Information",
|
||||
"Microsoft.AspNetCore": "Warning"
|
||||
}
|
||||
}
|
||||
}
|
||||
9
bin/Debug/net9.0/appsettings.json
Normal file
9
bin/Debug/net9.0/appsettings.json
Normal file
@ -0,0 +1,9 @@
|
||||
{
|
||||
"Logging": {
|
||||
"LogLevel": {
|
||||
"Default": "Information",
|
||||
"Microsoft.AspNetCore": "Warning"
|
||||
}
|
||||
},
|
||||
"AllowedHosts": "*"
|
||||
}
|
||||
Binary file not shown.
BIN
bin/Debug/net9.0/cs/Microsoft.CodeAnalysis.CSharp.resources.dll
Normal file
BIN
bin/Debug/net9.0/cs/Microsoft.CodeAnalysis.CSharp.resources.dll
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
bin/Debug/net9.0/cs/Microsoft.CodeAnalysis.resources.dll
Normal file
BIN
bin/Debug/net9.0/cs/Microsoft.CodeAnalysis.resources.dll
Normal file
Binary file not shown.
Binary file not shown.
BIN
bin/Debug/net9.0/de/Microsoft.CodeAnalysis.CSharp.resources.dll
Normal file
BIN
bin/Debug/net9.0/de/Microsoft.CodeAnalysis.CSharp.resources.dll
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
bin/Debug/net9.0/de/Microsoft.CodeAnalysis.resources.dll
Normal file
BIN
bin/Debug/net9.0/de/Microsoft.CodeAnalysis.resources.dll
Normal file
Binary file not shown.
Binary file not shown.
BIN
bin/Debug/net9.0/es/Microsoft.CodeAnalysis.CSharp.resources.dll
Normal file
BIN
bin/Debug/net9.0/es/Microsoft.CodeAnalysis.CSharp.resources.dll
Normal file
Binary file not shown.
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user