Add project files.

This commit is contained in:
user
2026-05-13 21:51:16 +02:00
parent 9bba670e7a
commit 7e8c24333e
11 changed files with 278 additions and 0 deletions

3
practise-05.slnx Normal file
View File

@@ -0,0 +1,3 @@
<Solution>
<Project Path="practise-05/practise-05.csproj" />
</Solution>

View File

@@ -0,0 +1,81 @@
using Microsoft.AspNetCore.Mvc;
namespace practise_05.Controllers
{
[ApiController]
[Route("[controller]")]
public class DeveleperController : ControllerBase
{
private static List<Developer> developerList = new List<Developer>()
{
new Developer {
Id= "b8878c6c-eda2-35ee-f621-91f9b7af14dc",
Name="Kiss Lajos",
Email="KissLajos@nikuni.hu",
Job="Frontend Developer",
Age=35,
Salary=350000,
Image="https://randomuser.me/api/portraits/men/1.jpg",
Skills= new string[] {
"User Research",
"Wireframing",
"Prototyping",
"Figma",
"Sketch",
"Interaction Design",
"Visual Design"
},
}
};
private static string next = "asdasd";
[HttpGet("/getAllDevelopers")]
public ActionResult<IEnumerable<Developer>> Get()
{
return Ok(developerList);
}
[HttpGet("/getDeveloperById/{id}")]
public ActionResult<Developer> GetDeveloper(string id)
{
return Ok(developerList.First(x => x.Id == id));
}
[HttpPost("/CreateDeveloper")]
public IActionResult PostDeveloper([FromBody] DeveloperPost developer)
{
Developer ffgh = new Developer();
ffgh.Id = next;
ffgh.Name = developer.Name;
ffgh.Email = developer.Email;
ffgh.Job = developer.Job;
ffgh.Age = developer.Age;
ffgh.Salary = developer.Salary;
ffgh.Image = developer.Image;
ffgh.Skills = developer.Skills;
developerList.Add(ffgh);
next = next + "asd";
return Created();
}
[HttpPut("/updateDeveloper/{id}")]
public IActionResult UpdateDev([FromBody] DeveloperPost developer, string id)
{
developerList = developerList.Where(x => x.Id != id).ToList();
Developer ffgh = new Developer();
ffgh.Id = id;
ffgh.Name = developer.Name;
ffgh.Email = developer.Email;
ffgh.Job = developer.Job;
ffgh.Age = developer.Age;
ffgh.Salary = developer.Salary;
ffgh.Image = developer.Image;
ffgh.Skills = developer.Skills;
developerList.Add(ffgh);
return CreatedAtAction(nameof(GetDeveloper), new {id = id}, ffgh);
}
}
}

View File

@@ -0,0 +1,34 @@
using Microsoft.AspNetCore.Mvc;
namespace practise_05.Controllers
{
[ApiController]
[Route("[controller]")]
public class WeatherForecastController : ControllerBase
{
private static readonly string[] Summaries = new[]
{
"Freezing", "Bracing", "Chilly", "Cool", "Mild", "Warm", "Balmy", "Hot", "Sweltering", "Scorching"
};
private readonly ILogger<WeatherForecastController> _logger;
public WeatherForecastController(ILogger<WeatherForecastController> logger)
{
_logger = logger;
}
[HttpGet(Name = "GetWeatherForecast")]
public IEnumerable<WeatherForecast> Get()
{
return Enumerable.Range(1, 5).Select(index => new WeatherForecast
{
Date = DateOnly.FromDateTime(DateTime.Now.AddDays(index)),
TemperatureC = Random.Shared.Next(-20, 55),
Summary = Summaries[Random.Shared.Next(Summaries.Length)]
})
.ToArray();
}
}
}

41
practise-05/Developer.cs Normal file
View File

@@ -0,0 +1,41 @@
namespace practise_05
{
public class Developer
{
string id;
string name;
string email;
string job;
int age;
int salary;
string image;
string[] skills;
public string Id { get => id; set => id = value; }
public string Name { get => name; set => name = value; }
public string Email { get => email; set => email = value; }
public string Job { get => job; set => job = value; }
public int Age { get => age; set => age = value; }
public int Salary { get => salary; set => salary = value; }
public string Image { get => image; set => image = value; }
public string[] Skills { get => skills; set => skills = value; }
}
public class DeveloperPost
{
string name;
string email;
string job;
int age;
int salary;
string image;
string[] skills;
public string Name { get => name; set => name = value; }
public string Email { get => email; set => email = value; }
public string Job { get => job; set => job = value; }
public int Age { get => age; set => age = value; }
public int Salary { get => salary; set => salary = value; }
public string Image { get => image; set => image = value; }
public string[] Skills { get => skills; set => skills = value; }
}
}

45
practise-05/Program.cs Normal file
View File

@@ -0,0 +1,45 @@
namespace practise_05
{
public class Program
{
public static void Main(string[] args)
{
var builder = WebApplication.CreateBuilder(args);
// Add services to the container.
builder.Services.AddControllers();
// Learn more about configuring OpenAPI at https://aka.ms/aspnet/openapi
builder.Services.AddOpenApi();
builder.Services.AddEndpointsApiExplorer();
builder.Services.AddSwaggerGen();
var app = builder.Build();
// Configure the HTTP request pipeline.
if (app.Environment.IsDevelopment())
{
app.MapOpenApi();
app.UseSwagger();
app.UseSwaggerUI();
}
app.UseHttpsRedirection();
app.UseAuthorization();
app.UseCors(x =>
{
x.AllowCredentials();
x.WithOrigins("http://127.0.0.1:5500");
x.AllowAnyMethod();
x.AllowAnyHeader();
});
app.MapControllers();
app.Run();
}
}
}

View File

@@ -0,0 +1,23 @@
{
"$schema": "https://json.schemastore.org/launchsettings.json",
"profiles": {
"http": {
"commandName": "Project",
"dotnetRunMessages": true,
"launchBrowser": false,
"applicationUrl": "http://localhost:5188",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"https": {
"commandName": "Project",
"dotnetRunMessages": true,
"launchBrowser": false,
"applicationUrl": "https://localhost:7163;http://localhost:5188",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
}
}
}

View File

@@ -0,0 +1,13 @@
namespace practise_05
{
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; }
}
}

View File

@@ -0,0 +1,8 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
}
}

View File

@@ -0,0 +1,9 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
},
"AllowedHosts": "*"
}

View File

@@ -0,0 +1,15 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>net9.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<RootNamespace>practise_05</RootNamespace>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.OpenApi" Version="9.0.16" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.6.2" />
</ItemGroup>
</Project>

View File

@@ -0,0 +1,6 @@
@practise_05_HostAddress = http://localhost:5188
GET {{practise_05_HostAddress}}/weatherforecast/
Accept: application/json
###