using Newtonsoft.Json;
using System;
using WK_KLI_LAPS_Service.App_Data;
using WK_KLI_LAPS_Service.Models;

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

namespace WK_KLI_LAPS_Service.Controllers.UserManagement.StageMapping
{
    public interface ITopBarMenu
    {
        object GetUserPreferences(userpreferenceModel userpreference);
        object AddUserPreferences(userpreferenceModel userpreference);
        object UpadateUserPreferences(userpreferenceModel userpreference,string updatetype);
        
    }

    public class TopBarMenuService : ITopBarMenu
    {
        CommonRepository oCommonRepository = new CommonRepository();

        public object GetUserPreferences(userpreferenceModel userpreference)
        {
            var data = JsonConvert.SerializeObject(userpreference);
            var res = oCommonRepository.ExecuteSP_ReturnList("spuserpreferenceselect", data, "getbyuserid");
            return res;
        }
        public object AddUserPreferences(userpreferenceModel userpreference)
        {
            var data = JsonConvert.SerializeObject(userpreference);
            var res = oCommonRepository.ExecuteSP_ReturnList("spuserpreference", data, "insert");
            return res;
        }
        public object UpadateUserPreferences(userpreferenceModel userpreference,string updatetype)
        {
            string mode = String.Empty; ;
            if (updatetype== "showandhideupdate")
                mode = "updatehideandshow";
            else 
                mode = "updateminandmax";
                var data = JsonConvert.SerializeObject(userpreference);
            var res = oCommonRepository.ExecuteSP_ReturnList("spuserpreference", data, "update");
            return res;
        }
    }
}
