using Microsoft.AspNetCore.Mvc;
using UnivateProperties_API.Repository.Properties;

namespace UnivateProperties_API.Controllers.Properties
{
    [Route("api/[controller]")]
    [ApiController]
    public class PropertyFieldsController : ControllerBase
    {
        private readonly IUserDefinedGroupRepository _Repo;

        public PropertyFieldsController(IUserDefinedGroupRepository repo)
        {
            _Repo = repo;
        }

        [HttpGet]
        public IActionResult Get()
        {
            return new OkObjectResult(_Repo.GetFieldList(""));
        }

        [HttpGet("{name}")]
        public IActionResult Get(string name)
        {
            return new OkObjectResult(_Repo.GetFieldList(name));
        }

        [HttpGet("{PropertyType}/{type}")]
        public IActionResult Get(string PropertyType, string type)
        {
            return new OkObjectResult(_Repo.GetFieldListByPropType(type));
        }

        [HttpGet("GetSavedValues/{propertyType}/{name}/{id}")]
        public IActionResult GetSavedValues(string propertyType, string name, int id)
        {
            return new OkObjectResult(_Repo.GetFieldList(propertyType, name, id));
        }

        [HttpGet("GetSavedPropertyUserFields/{id}")]
        public IActionResult GetSavedPropertyUserFields(int id)
        {
            return new OkObjectResult(_Repo.GetSavedList(id));
        }
    }


}