Пример #1
0
 public static bool CheckCompta(Collaborator coll)
 {
     if (coll.Service != null)
     {
         return(coll.Service.Name.Contains("Compta") ? true : false);
     }
     return(false);
 }
Пример #2
0
 public static bool CheckDirection(Collaborator coll)
 {
     if (coll.Service != null)
     {
         return(coll.Service.Name.Contains("Direction") ? true : false);
     }
     return(false);
 }
Пример #3
0
 public Notification(Collaborator transmitter, Collaborator receiver, NotificationType notifType, NotificationResult notifResult, string notifContent)
 {
     Transmitter  = transmitter;
     Receiver     = receiver;
     NotifStatus  = NotificationStatus.UNREAD;
     NotifType    = notifType;
     NotifManage  = NotificationManage.RESULT;
     NotifResult  = notifResult;
     NotifContent = notifContent;
 }
Пример #4
0
 public Notification(Collaborator transmitter, Collaborator receiver, NotificationType notifType)
 {
     Transmitter = transmitter;
     Receiver    = receiver;
     NotifStatus = NotificationStatus.UNREAD;
     NotifType   = notifType;
     NotifManage = NotificationManage.MANAGE;
     NotifResult = NotificationResult.TREATMENT;
     Content();
 }
Пример #5
0
        public static List <Mission> GetAllMissionsFromAService(Collaborator coll)
        {
            List <Mission> list = new List <Mission>();

            Dal dal = new Dal();

            foreach (Mission miss in dal.GetMissions())
            {
                if (miss.ChiefId == coll.Id)
                {
                    list.Add(miss);
                }
            }

            return(list);
        }
Пример #6
0
        public static int GetNumberLeave(Collaborator coll, LeaveStatus status1, LeaveStatus status2, LeaveType type)
        {
            Dal dal    = new Dal();
            int number = 0;

            foreach (Leave l in dal.GetLeaves())
            {
                if ((l.Collaborator.Id == coll.Id) && CheckIfDateIsCurrentYear(l.StartDate))
                {
                    if ((l.Status == status1 | l.Status == status2) && l.Type == type)
                    {
                        number += l.ComputeLengthLeave();
                    }
                }
            }
            return(number);
        }
Пример #7
0
        public static HelperProcessing ComputeTreatmentLeave(Collaborator coll)
        {
            Service s    = coll.Service;
            Roles   role = coll.Role;


            switch (role)
            {
            case Roles.USER:
                if (CheckRH(coll))
                {
                    // Coll RH => double val DHR
                    return(HelperProcessing.DHR);
                }
                else
                {
                    // Cas classique
                    return(HelperProcessing.CLASSIC);
                }

            case Roles.CHIEF:
                if (s.Name.Contains("Compta"))
                {
                    // CDS compta => double val RH
                    return(HelperProcessing.HR);
                }
                else if (s.Name.Contains("RH"))
                {
                    // CDS RH => double val PDG
                    return(HelperProcessing.CEO);
                }
                else if (s.Name.Contains("Direction"))
                {
                    // PDG => double val DRH
                    return(HelperProcessing.DHR);
                }
                else
                {
                    return(HelperProcessing.HR);
                }

            default:
                return(HelperProcessing.CLASSIC);
            }
        }
Пример #8
0
        public static HelperProcessing ComputeTreatmentER(Collaborator coll)
        {
            Service s    = coll.Service;
            Roles   role = coll.Role;

            switch (role)
            {
            case Roles.USER:
                if (s.Name.Contains("Compta"))
                {
                    // Coll compta => double val DF
                    return(HelperProcessing.FINANCIAL_DIRECTOR);
                }
                else
                {
                    // Cas classique
                    return(HelperProcessing.CLASSIC);
                }

            case Roles.CHIEF:
                if (s.Name.Contains("Compta"))
                {
                    // CDS compta => double val PDG
                    return(HelperProcessing.CEO);
                }
                else if (s.Name.Contains("RH"))
                {
                    // CDS RH => double val compta
                    return(HelperProcessing.COMPTA);
                }
                else if (s.Name.Contains("Direction"))
                {
                    // PDG => double val DF
                    return(HelperProcessing.FINANCIAL_DIRECTOR);
                }
                else
                {
                    return(HelperProcessing.COMPTA);
                }

            default:
                return(HelperProcessing.CLASSIC);
            }
        }
Пример #9
0
        public static bool IsERTreated(ExpenseReport er, Collaborator coll)
        {
            bool treated = true;

            if (er.Status == ExpenseReportStatus.PENDING_APPROVAL_1)
            {
                foreach (ExpenseLine el in er.ExpenseLines)
                {
                    if (el.Mission.ChiefId == coll.Id)
                    {
                        treated = treated && (el.Treated == Treatment.CDS);
                    }
                }
            }
            else
            {
                treated = false;
            }

            return(treated);
        }
Пример #10
0
 //public enum Treatment
 //{
 //	NOT_TREATED,
 //	CDS,
 //	COMPTA
 //}
 //true if the coll is in a management role (RH, Compta or Chief)
 public static bool CheckManagement(Collaborator coll)
 {
     return((CheckCompta(coll) || CheckRH(coll) || CheckDirection(coll)) || CheckCDS(coll) ? true : false);
 }
Пример #11
0
 public static bool CheckAdmin(Collaborator coll)
 {
     return(coll.Role == Casablanca.Models.Roles.ADMIN ? true : false);
 }
Пример #12
0
 public static bool CheckCDS(Collaborator coll)
 {
     return(coll.Role == Roles.CHIEF ? true : false);
 }
Пример #13
0
 public Service(string name)
 {
     Name     = name;
     CollList = new List <Collaborator>();
     Chief    = null;
 }
Пример #14
0
 public static bool CheckPDG(Collaborator coll)
 {
     return(coll.Role == Roles.CHIEF && coll.Service.Name.Contains("Direction") ? true : false);
 }
Пример #15
0
 public static bool CheckCDSRH(Collaborator coll)
 {
     return(coll.Role == Roles.CHIEF && coll.Service.Name.Contains("RH") ? true : false);
 }
 public IEnumerable <Notification> GetNotifications(Collaborator coll)
 {
     return(_dal.GetNotifications(coll));
 }
Пример #17
0
        public static int GetNumberERToProcess(Collaborator coll)
        {
            int number = 0;

            Dal dal = new Dal();
            List <ExpenseReport> AllERList = dal.GetExpenseReports();

            // for each Expense Report, check if they meet the following criterias
            // if yes, add them to the list returned to the View
            foreach (ExpenseReport e in AllERList)
            {
                if (e.Collaborator != coll)                 // a coll cannot validate his own ER
                {
                    // If the ER needs to be treated the classic way
                    if (e.Treatment == ExpenseReports.Processing.CLASSIC)
                    {
                        if (HelperModel.CheckCDSCompta(coll))                         // CDS Compta
                        {
                            if (e.Status == ExpenseReportStatus.PENDING_APPROVAL_2)
                            {
                                ++number;
                            }
                            if (e.Status == ExpenseReportStatus.PENDING_APPROVAL_1)
                            {
                                // in order to know if the Chief needs to see the ER, check if coll is the chief of a mission in ELs
                                foreach (ExpenseLine el in e.ExpenseLines)
                                {
                                    if (dal.GetCollaborator(el.Mission.ChiefId).Id == coll.Id)
                                    {
                                        ++number;
                                        break;
                                    }
                                }
                            }
                        }
                        else if (HelperModel.CheckCompta(coll))                         // Compta
                        {
                            if (e.Status == ExpenseReportStatus.PENDING_APPROVAL_2)
                            {
                                ++number;
                            }
                        }
                        else if (HelperModel.CheckCDS(coll))                         // CDS
                        {
                            if (e.Status == ExpenseReportStatus.PENDING_APPROVAL_1)
                            {
                                // in order to know if the Chief needs to see the ER
                                foreach (ExpenseLine el in e.ExpenseLines)
                                {
                                    if (dal.GetCollaborator(el.Mission.ChiefId).Id == coll.Id)
                                    {
                                        ++number;
                                        break;
                                    }
                                }
                            }
                        }
                    }
                    else
                    {                     // The ER needs to be treated specifically
                        if (e.Status == ExpenseReportStatus.PENDING_APPROVAL_1)
                        {
                            switch (e.Treatment)
                            {
                            case ExpenseReports.Processing.COMPTA:
                                if (HelperModel.CheckCompta(coll))
                                {
                                    ++number;
                                }
                                break;

                            case ExpenseReports.Processing.FINANCIAL_DIRECTOR:
                                if (HelperModel.CheckCDSCompta(coll))
                                {
                                    ++number;
                                }
                                break;

                            case ExpenseReports.Processing.CEO:
                                if (HelperModel.CheckPDG(coll))
                                {
                                    ++number;
                                }
                                break;
                            }
                        }
                    }
                }
            }

            return(number);
        }
Пример #18
0
        public static int GetNumberLeaveToProcess(Collaborator coll)
        {
            int number = 0;

            Dal dal = new Dal();

            List <Leave> LeaveListToBeReturnedAsModel = new List <Leave>();

            List <Leave> allLeaves = dal.GetLeaves();

            // for each Leave, check if they meet the following criterias
            // if yes, ++number;
            foreach (Leave e in allLeaves)
            {
                if (e.Collaborator != coll)                 // a coll cannot validate his own ER
                {
                    // If the ER needs to be treated the classic way
                    if (e.Treatment == HelperProcessing.CLASSIC)
                    {
                        if (HelperModel.CheckCDSRH(coll))                         // CDS RH
                        {
                            if (e.Status == LeaveStatus.PENDING_APPROVAL_2)
                            {
                                ++number;
                            }
                            if (e.Status == LeaveStatus.PENDING_APPROVAL_1)
                            {
                                if (e.Collaborator.Service.GetChiefFromService() == coll.Id)
                                {
                                    ++number;
                                }
                            }
                        }
                        else if (HelperModel.CheckRH(coll))                         // RH
                        {
                            if (e.Status == LeaveStatus.PENDING_APPROVAL_2)
                            {
                                ++number;
                            }
                        }
                        else if (HelperModel.CheckCDS(coll))                         // CDS
                        {
                            if (e.Status == LeaveStatus.PENDING_APPROVAL_1)
                            {
                                // in order to know if the Chief needs to see the leave

                                if (e.Collaborator.Service.GetChiefFromService() == coll.Id)
                                {
                                    ++number;
                                }
                            }
                        }
                    }


                    else
                    {                                                   // The ER needs to be treated specifically
                        if (e.Status == LeaveStatus.PENDING_APPROVAL_1) // please do not put pending2 in DAL for those leaves
                        {
                            switch (e.Treatment)
                            {
                            case HelperProcessing.DHR:
                                if (HelperModel.CheckCDSRH(coll))                                         //si le coll traiteur est un CDSRH
                                {
                                    ++number;
                                }
                                break;

                            case HelperProcessing.HR:
                                if (HelperModel.CheckRH(coll))
                                {
                                    ++number;
                                }
                                break;

                            case HelperProcessing.CEO:
                                if (HelperModel.CheckPDG(coll))
                                {
                                    ++number;
                                }
                                break;
                            }
                        }
                    }
                }
            }

            return(number);
        }