using System;
using System.Web.Http;
using iiie.WebApiUtils.BusinessManager;
using iiie.WebApiUtils.DBO;
using WebAPiUtils_test.BusinessManager;
using WebAPiUtils_test.DBO;

namespace WebAPiUtils_test.Controllers
{
    public class ValuesController : ApiController
    {
        [HttpGet]
        [Route("api/values/{id}")]
        public ValuesDboGet Get(int id)
        {
            return BMRHandler<ValuesDboGet>.Handle(ValuesBusiness.Get(id), Request);
        }

        [HttpGet]
        [Route("api/values/contains")]
        public DboGetMultiple<ValuesDboGet> Contains(string text, int page = 0, int perPage = Int32.MaxValue)
        {
            return BMRHandler<DboGetMultiple<ValuesDboGet>>.Handle(ValuesBusiness.Contains(text, page, perPage), Request);
        }

        [HttpPost]
        [Route("api/values/edit/{id}")]
        public bool Edit(long id, ValuesDboEdit obj)
        {
            return BMRHandler<bool>.Handle(ValuesBusiness.Edit(obj, id), Request);
        }

        [HttpPost]
        [Route("api/values/add")]
        public long Add(ValuesDboAdd obj)
        {
            return BMRHandler<long>.Handle(ValuesBusiness.Add(obj), Request);
        }

        [HttpPost]
        [Route("api/values/adddbo")]
        public ValuesDboGet AddDbo(ValuesDboAdd obj)
        {
            return BMRHandler<ValuesDboGet>.Handle(ValuesBusiness.AddDbo(obj), Request);
        }
    }
}
