/
ColorsController.cs
78 lines (71 loc) · 1.88 KB
/
ColorsController.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
using Business.Abstract;
using Entities.Concrete;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
namespace WebAPI.Controllers
{
[Route("api/[controller]")]
[ApiController]
public class ColorsController : ControllerBase
{
IColorService _colorService;
public ColorsController(IColorService colorService)
{
_colorService = colorService;
}
[HttpGet("getall")]
public IActionResult GetAll()
{
var result = _colorService.GetAll();
if (result.Success)
{
return Ok(result);
}
return BadRequest(result);
}
[HttpGet("getbyid")]
public IActionResult GetById(int id)
{
var result = _colorService.GetById(id);
if (result.Success)
{
return Ok(result);
}
return BadRequest(result);
}
[HttpPost("add")]
public IActionResult Add(Color color)
{
var result = _colorService.Add(color);
if (result.Success)
{
return Ok(result);
}
return BadRequest(result);
}
[HttpPost("delete")]
public IActionResult Delete(Color color)
{
var result = _colorService.Delete(color);
if (result.Success)
{
return Ok(result);
}
return BadRequest(result);
}
[HttpPost("update")]
public IActionResult Update(Color color)
{
var result = _colorService.Update(color);
if (result.Success)
{
return Ok(result);
}
return BadRequest(result);
}
}
}