using Chloe.Server.Dtos;
using Chloe.Server.Services.Contracts;
using System.Collections.Generic;
using System.Web.Http;
using System.Web.Http.Description;

namespace Chloe.Server.Controllers
{
    [Authorize]
    [RoutePrefix("api/v1/carouselComponent")]
    public class CarouselComponentController : ApiController
    {
        public CarouselComponentController(ICarouselComponentService service)
        {
            this.service = service;
        }

        [Route("add")]
        [HttpPost]
		[ResponseType(typeof(CarouselComponentAddOrUpdateResponseDto))]
        public IHttpActionResult Add(CarouselComponentAddOrUpdateRequestDto dto) { return Ok(this.service.AddOrUpdate(dto)); }

        [Route("update")]
        [HttpPut]
		[ResponseType(typeof(CarouselComponentAddOrUpdateResponseDto))]
        public IHttpActionResult Update(CarouselComponentAddOrUpdateRequestDto dto) { return Ok(this.service.AddOrUpdate(dto)); }

        [Route("get")]
        [AllowAnonymous]
        [HttpGet]
		[ResponseType(typeof(ICollection<CarouselComponentDto>))]
        public IHttpActionResult Get() { return Ok(this.service.Get()); }

		[Route("getById")]
        [HttpGet]
		[ResponseType(typeof(CarouselComponentDto))]
        public IHttpActionResult GetById(int id) { return Ok(this.service.GetById(id)); }
        
        [Route("remove")]
        [HttpDelete]
		[ResponseType(typeof(int))]
        public IHttpActionResult Remove(int id) { return Ok(this.service.Remove(id)); }

        protected readonly ICarouselComponentService service;

    }
}
