82 lines
2.5 KiB
C#
82 lines
2.5 KiB
C#
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);
|
|
}
|
|
|
|
|
|
}
|
|
}
|