﻿using Bivi.Data.Context;
using Bivi.Domaine;
using Bivi.Business.Depots;
using System.Linq;
using System;
using Bivi.Domaine.Caching;
using System.Collections.Generic;
using AutoMapper;

namespace Bivi.Data.Depots
{
    public partial class DepotPersonneSiteConf : Depot<PersonneSiteConf>, IDepotPersonneSiteConf
    {
        public PersonneSiteConf GetByUserSite(long userID, long siteID)
        {
            return DbContext.PersonneSiteConfs.FirstOrDefault( b => b.SiteID == siteID && b.PersonneID == userID);
        }

        public bool UpdateStatutHomePersonnalisee(long userID, long siteID, bool active)
        {
            var conf = GetByUserSite(userID, siteID);

            if (conf != null)
            {
                conf.BoolHomePerso = active;
                Update();
                return true;
            }
            else
            {
                return false;
            }

        }
    }
}