예제 #1
0
        /// <summary>
        ///     Permet de savoir si l'utilisateur peut ajouter un employé
        /// </summary>
        /// <param name="admin">Admin</param>
        /// <returns>bool</returns>
        public bool AuthorizedAddEmploye(AdministrateurFranchise admin = null)
        {
            try
            {
                if (admin.IsNull()) return false;
                var g = Franchises.Where(f => f.Id == admin.IdFranchise).Include(f => f.Salons).ToList();
                var franchise = Franchises.Include(f => f.Salons).FirstOrDefault(f => f.Id == admin.IdFranchise);
                if (franchise.IsNull()) return false;

                return franchise.Salons.Count != 0;
                //var c = Franchises.Where(f => f.Id == admin.IdFranchise).Include(f => f.Salons).Select(f => f.Salons).Count() != 0;

                //return c;
            }
            catch (Exception)
            {
                return false;
            }
        }
예제 #2
0
        /// <summary>
        ///     Permet de récupérer le nombre de salons que l'utilisateur peut encore ajouter
        /// </summary>
        /// <param name="admin">AdministrateurFranchise</param>
        /// <returns>int</returns>
        public int GetNombreSalonsRestant(AdministrateurFranchise admin = null)
        {
            try
            {
                if (admin.IsNull()) return 0;

                var max =
                    Franchises.FirstOrDefault(f => f.Id == admin.IdFranchise);

                var salonActuel = GetNombreSalon(admin);
                return salonActuel;
            }
            catch (Exception)
            {
                return 0;
            }
        }
예제 #3
0
        /// <summary>
        ///     Permet de savoir si l'utilisateur peut ajouter un salon
        /// </summary>
        /// <param name="admin">Admin</param>
        /// <returns>bool</returns>
        public bool AutorizedAddSalon(AdministrateurFranchise admin = null)
        {
            try
            {
                if (admin.IsNull()) return false;

                return GetNombreSalonsRestant(admin) != 0;
            }
            catch (Exception)
            {
                return false;
            }
        }
예제 #4
0
        /// <summary>
        ///     Permet de récupérer le nombre de salons
        /// </summary>
        /// <param name="admin">AdministrateurFranchise</param>
        /// <returns>int</returns>
        public int GetNombreSalon(AdministrateurFranchise admin = null)
        {
            try
            {
                if (admin.IsNull()) return 0;

                var franchise = GetFranchiseById(admin.IdFranchise);
                if (franchise.IsNull()) return 0;

                return franchise.FicheFranchise.NombreSalon;
                //return Franchises.Where(f => f.Id == admin.IdFranchise).SelectMany(f => f.Salons).Count();
            }
            catch (Exception)
            {
                return 0;
            }
        }
예제 #5
0
        /// <summary>
        ///     Permet de récupérer le nombre d'employé total d'une franchise
        /// </summary>
        /// <param name="admin">AdministrateurFranchise</param>
        /// <returns>int</returns>
        public int GetNombreEmployes(AdministrateurFranchise admin = null)
        {
            try
            {
                if (admin.IsNull()) return 0;

                var franchise = GetFranchiseById(admin.IdFranchise);
                if (franchise.IsNull()) return 0;
                return franchise.FicheFranchise.NombreEmployes;
                //Franchises.Where(f => f.Id == admin.IdFranchise)
                //    .SelectMany(f => f.Salons).Include(s => s.FicheSalon)
                //    .Sum(s => s.FicheSalon.NombreEmployes);

                //return
                //    Franchises.Where(f => f.Id == admin.IdFranchise)
                //        .SelectMany(f => f.Salons)
                //        .SelectMany(s => s.ListeEmployes)
                //        .Count();
            }
            catch (Exception)
            {
                return 0;
            }
        }
예제 #6
0
        /// <summary>
        ///     Permet de récupérer tous les employés des salons via un AdministrateurFranchise
        /// </summary>
        /// <param name="admin">AdministrateurFranchise</param>
        /// <returns>List{Salon}</returns>
        public List<Employe> GetEmployes(AdministrateurFranchise admin = null)
        {
            try
            {
                if (admin.IsNull()) return new List<Employe>();

                return
                    Franchises.Where(f => f.Id == admin.IdFranchise)
                        .SelectMany(f => f.Salons)
                        .SelectMany(s => s.ListeEmployes).Distinct()
                        .Include(e => e.Salon)
                        .Include(s => s.Salon.FicheSalon)
                        .ToList();
            }
            catch (Exception)
            {
                return new List<Employe>();
            }
        }
예제 #7
0
        public bool AccessEmploye(int? idEmploye, AdministrateurFranchise admin = null)
        {
            try
            {
                if (idEmploye.IsNull() || admin.IsNull()) return false;

                return
                    Users.OfType<Employe>()
                        .Include(e => e.Salon)
                        .Where(u => u.Id == idEmploye)
                        .FirstOrDefault()
                        .IsNotNull();
            }
            catch (Exception)
            {
                return false;
            }
        }
예제 #8
0
        /// <summary>
        ///     Permet de récupérer les salons via un AdministrateurFranchise
        /// </summary>
        /// <param name="admin">AdministrateurFranchise</param>
        /// <returns>List{Salon}</returns>
        public List<Salon> GetSalons(AdministrateurFranchise admin = null)
        {
            try
            {
                if (admin.IsNull()) return new List<Salon>();

                return Franchises.Where(f => f.Id == admin.IdFranchise).SelectMany(f => f.Salons).Include(s => s.ListeEmployes)
                    .Include(s => s.PrestationClients).Include(s => s.FicheSalon).Include(s => s.Abonnement).ToList();
            }
            catch (Exception)
            {
                return new List<Salon>();
            }
        }