using Newtonsoft.Json;
using WK_KLI_LAPS_Service.App_Data;

// For more information on enabling MVC for empty projects, visit https://go.microsoft.com/fwlink/?LinkID=397860

namespace WK_KLI_LAPS_Service.Controllers.Configuration.UserManagement.RoleMapping
{
    public interface IUserRoleMappingService
    {
        // IEnumerable<object> GetAll();
        // IEnumerable<object> GetActiveuUerProjectMapping();
        object Add(string inputstr, string mode);
        object GetById(int data, string mode);
        object UpdateRoleProjectOnEmpty(string inputstr, string mode);
    }

    public class UserRoleMappingService : IUserRoleMappingService
    {
        CommonRepository oCommonRepository = new CommonRepository();
        public object Add(string inputstr, string mode)
        {
            string query = @"public.spuserrolemapping";
            return oCommonRepository.ExecuteSP_ReturnList(query, inputstr, mode);
        }

        //method to retrieve the user role mapping definition details based on role id
        public object GetById(int data, string mode)
        {
            var userrolemapping = new { roleid = data };
            var jsonstr = JsonConvert.SerializeObject(userrolemapping);
            string query = @"public.spuserrolemappingselect";
            return oCommonRepository.ExecuteSP_ReturnList(query, jsonstr, mode);
        }
        public object UpdateRoleProjectOnEmpty(string inputstr, string mode)
        {
            string query = @"public.spuserrolemapping";
            return oCommonRepository.ExecuteSP_ReturnList(query, inputstr, mode);
        }
    }
}
