vreksam/WebApi/Controllers/FoorumController.cs

57 lines
1.3 KiB
C#
Raw Normal View History

2017-06-12 12:46:00 +03:00
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Web.Http;
2017-06-12 13:37:48 +03:00
using BL.DTOs;
using BL.Interfaces;
2017-06-12 12:46:00 +03:00
namespace WebApi.Controllers
{
public class FoorumController : ApiController
{
2017-06-12 13:37:48 +03:00
private IFoorumService _foorumService;
public FoorumController(IFoorumService foorumService)
{
_foorumService = foorumService;
}
2017-06-12 12:46:00 +03:00
// GET api/<controller>
2017-06-12 13:37:48 +03:00
public IEnumerable<FoorumDTO> Get()
2017-06-12 12:46:00 +03:00
{
2017-06-12 13:37:48 +03:00
return _foorumService.GetAll();
2017-06-12 12:46:00 +03:00
}
// GET api/<controller>/5
public string Get(int id)
{
return "value";
}
// POST api/<controller>
2017-06-12 14:16:38 +03:00
public IHttpActionResult Post([FromBody]FoorumDTO foorum)
2017-06-12 12:46:00 +03:00
{
2017-06-12 14:16:38 +03:00
if (foorum == null)
{
return BadRequest();
}
var ret = _foorumService.Add(foorum);
if (ret != null)
{
return CreatedAtRoute("DefaultApi", new {controller = "Foorum", id = ret.FoorumId}, ret);
}
return BadRequest();
2017-06-12 12:46:00 +03:00
}
// PUT api/<controller>/5
public void Put(int id, [FromBody]string value)
{
}
// DELETE api/<controller>/5
public void Delete(int id)
{
}
}
}