﻿using Bivi.Business.Depots;
using Bivi.Domaine;
using System;
using System.Collections.Generic;
using System.Data.SqlClient;
using System.Linq;
using System.Text;

namespace Bivi.Data.Depots
{
    public partial class DepotCivilite : IDepotCivilite
    {
        public Civilite GetByCodeEchange(string codeEchange)
        {
            var query = from c in DbContext.Civilites
                        where c.CodeEchange.Equals(codeEchange)
                        select c;

            return query.FirstOrDefault();
        }

        public IEnumerable<DictionaryResult> GetCivilites(long personneID)
        {
            List<SqlParameter> parameters = new List<SqlParameter>();

            SqlParameter param = new SqlParameter("@PersonneID", System.Data.SqlDbType.BigInt) { Value = personneID };
            parameters.Add(param);

            return DbContext.ExecuteStoredProcedure<DictionaryResult>("sp_LireCivilites", parameters);
        }
    }
}
