示例#1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="startDate"></param>
        /// <param name="endDate"></param>
        internal static double StaticGetTotalPaidSalaries(DateTime?startDate, DateTime?endDate)
        {
            using (var db = new EconomatContext()) {
                if (!db.Payrolls.Any(t => !t.IsDeleted && t.IsPaid))
                {
                    return(0);
                }

                if (startDate == null || endDate == null)
                {
                    return(db.Payrolls.Where(t => !t.IsDeleted && t.IsPaid).Sum(t => t.FinalPaycheck));
                }

                if (!db.Payrolls.Any(t =>
                                     !t.IsDeleted && t.IsPaid &&
                                     t.DatePaid >= startDate &&
                                     t.DatePaid <= endDate
                                     ))
                {
                    return(0);
                }

                return(db.Payrolls.Where(t =>
                                         !t.IsDeleted && t.IsPaid &&
                                         t.DatePaid >= startDate &&
                                         t.DatePaid <= endDate
                                         ).Sum(t => t.FinalPaycheck));
            }
        }
示例#2
0
        /// <summary>
        /// Ajouter Un Recue a Payer Par l'Etudiant
        /// </summary>
        /// <param name="myBill"></param>
        /// <returns>True pour Success</returns>
        public bool AddFeeReceipt(StudentBill myBill)
        {
            if (myBill.NetAmount < 0.0000001)
            {
                return(true);
            }
            if (FeeReceiptExist(myBill))
            {
                return(true);
            }
            using (var db = new SchoolContext()) if (db.Students.Find(myBill.StudentGuid) == null)
                {
                    throw new InvalidOperationException("STUDENT_REFERENCE_NOT_FOUND");
                }

            using (var db = new EconomatContext())
            {
                var newSchoolFee = new SchoolFee
                {
                    SchoolFeeGuid = myBill.SchoolFeeGuid == Guid.Empty ? Guid.NewGuid() : myBill.SchoolFeeGuid,
                    StudentGuid   = myBill.StudentGuid,
                    Designation   = myBill.Designation,
                    NetAmount     = myBill.NetAmount,
                    DueDate       = myBill.DueDate,

                    DateAdded        = DateTime.Now,
                    AddUserGuid      = Guid.Empty,
                    LastEditUserGuid = Guid.Empty
                };

                db.SchoolFees.Add(newSchoolFee);
                return(db.SaveChanges() > 0);
            }
        }
示例#3
0
 /// <summary>
 /// Verifie si un recue avec ce numero exist
 /// </summary>
 /// <param name="theReference"></param>
 /// <returns></returns>
 public bool RefRecueExist(string theReference)
 {
     using (var mc = new EconomatContext())
         return
             (mc.SchoolFees.Any(
                  s => s.NumeroReference.Equals(theReference, StringComparison.CurrentCultureIgnoreCase)));
 }
示例#4
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="startDate"></param>
        /// <param name="endDate"></param>
        internal static double StaticGetSoldeCaisse(DateTime?startDate, DateTime?endDate)
        {
            using (var db = new EconomatContext()) {
                if (!db.Transactions.Any(t => !t.IsDeleted))
                {
                    return(0);
                }

                if (startDate == null || endDate == null)
                {
                    return(db.Transactions.Where(t => !t.IsDeleted).Sum(t => t.Amount));
                }

                if (!db.Transactions.Any(t =>
                                         !t.IsDeleted &&
                                         t.TransactionDate >= startDate &&
                                         t.TransactionDate <= endDate
                                         ))
                {
                    return(0);
                }

                return(db.Transactions.Where(t =>
                                             !t.IsDeleted &&
                                             t.TransactionDate >= startDate &&
                                             t.TransactionDate <= endDate
                                             ).Sum(t => t.Amount));
            }
        }
示例#5
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="newTransaction"></param>
        /// <returns></returns>
        internal static bool StaticNewTransaction(Transaction newTransaction)
        {
            //if(Math.Abs(newTransaction.Amount) < 0.000000000000000001)
            //   return true;

            if (TransactionExist(newTransaction))
            {
                throw new InvalidOperationException("TRANSACTION_REFERENCE_ALREADY_EXIST");
            }

            if (newTransaction.TransactionDate < DateTime.Today.AddDays(-1))
            {
                throw new InvalidOperationException("TRANSACTION_DATE_NOT_VALIDE");
            }

            using (var db = new EconomatContext())
            {
                newTransaction.TransactionGuid = newTransaction.TransactionGuid == Guid.Empty ? Guid.NewGuid() : newTransaction.TransactionGuid;
                var transDate = newTransaction.TransactionDate.GetValueOrDefault();
                newTransaction.TransactionDate = new DateTime(transDate.Year, transDate.Month, transDate.Day, DateTime.Now.Hour, DateTime.Now.Minute, DateTime.Now.Second);
                if (string.IsNullOrEmpty(newTransaction.Description))
                {
                    newTransaction.Description = newTransaction.Designation;
                }

                newTransaction.DateAdded        = DateTime.Now;
                newTransaction.AddUserGuid      = Guid.Empty;
                newTransaction.LastEditDate     = DateTime.Now;
                newTransaction.LastEditUserGuid = Guid.Empty;

                db.Transactions.Add(newTransaction);
                return(db.SaveChanges() > 0);
            }
        }
示例#6
0
 /// <summary>
 /// Verifie si cette reference exist
 /// </summary>
 /// <param name="theReference"></param>
 /// <returns></returns>
 public bool RefTransactionExist(string theReference)
 {
     using (var mc = new EconomatContext())
         return
             (mc.Transactions.Any(
                  s => s.TransactionReference.Equals(theReference, StringComparison.CurrentCultureIgnoreCase)));
 }
示例#7
0
 /// <summary>
 /// Verifie si un recue avec ce numero exist
 /// </summary>
 /// <param name="theReference"></param>
 /// <returns></returns>
 protected internal static bool SalarySlipExist(string theReference)
 {
     using (var mc = new EconomatContext())
         return
             (mc.Payrolls.Any(
                  s => s.NumeroReference.Equals(theReference, StringComparison.CurrentCultureIgnoreCase)));
 }
示例#8
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="startDate"></param>
        /// <param name="endDate"></param>
        internal static double StaticGetTotalPaidSchoolFee(DateTime?startDate, DateTime?endDate)
        {
            using (var db = new EconomatContext()) {
                if (!db.SchoolFees.Any(t => !t.IsDeleted && t.IsPaid))
                {
                    return(0);
                }

                if (startDate == null || endDate == null)
                {
                    return(db.SchoolFees.Where(t => !t.IsDeleted && t.IsPaid).Sum(t => t.NetAmount));
                }

                if (!db.SchoolFees.Any(t =>
                                       !t.IsDeleted && t.IsPaid &&
                                       t.DatePaid >= startDate &&
                                       t.DatePaid <= endDate
                                       ))
                {
                    return(0);
                }

                return(db.SchoolFees.Where(t =>
                                           !t.IsDeleted && t.IsPaid &&
                                           t.DatePaid >= startDate &&
                                           t.DatePaid <= endDate
                                           ).Sum(t => t.NetAmount));
            }
        }
示例#9
0
        /// <summary>
        /// liste des transactions
        /// </summary>
        /// <param name="startDate"></param>
        /// <param name="endDate"></param>
        /// <param name="includeDeleted"></param>
        /// <returns></returns>
        public IEnumerable GetTransactions(DateTime?startDate, DateTime?endDate, bool includeDeleted = false)
        {
            if (includeDeleted)
            {
                using (var db = new EconomatContext())
                {
                    if (startDate == null || endDate == null)
                    {
                        return
                            (db.Transactions.OrderByDescending(t => t.TransactionDate)
                             .ToList()
                             .Select(t => new TransactionCard(t)));
                    }

                    return(db.Transactions.Where(t =>
                                                 t.TransactionDate >= startDate &&
                                                 t.TransactionDate <= endDate
                                                 ).OrderByDescending(t => t.TransactionDate).ToList().Select(t => new TransactionCard(t)));
                }
            }

            using (var db = new EconomatContext()) {
                if (startDate == null || endDate == null)
                {
                    return(db.Transactions.Where(t => !t.IsDeleted).OrderByDescending(t => t.TransactionDate).ToList().Select(t => new TransactionCard(t)));
                }

                return(db.Transactions.Where(t => !t.IsDeleted &&
                                             t.TransactionDate >= startDate &&
                                             t.TransactionDate <= endDate
                                             ).OrderByDescending(t => t.TransactionDate).ToList().Select(t => new TransactionCard(t)));
            }
        }
示例#10
0
        /// <summary>
        /// les donnee concernant une salaire
        /// </summary>
        public PayrollCard(Payroll payroll)
        {
            PayrollGuid = payroll.PayrollGuid;
            Designation = payroll.Designation;
            IsPaid      = payroll.IsPaid;
            TotalSalary = 0;

            Employment employ;

            using (var db = new EconomatContext()) employ = db.Employments.Find(payroll.EmploymentGuid);

            var payrollStart = employ.SalaryRecurrence == InstallmentRecurrence.Once ? employ.StartDate.GetValueOrDefault()
                               : payroll.PaycheckDate.GetValueOrDefault().AddMonths(-((int)employ.SalaryRecurrence));

            switch (employ.PayType)
            {
            case PayType.HoursTaught:
                TotalSalary = PayrollManager.StaticGetTeachingSalary(employ.StaffGuid, payrollStart, payroll.PaycheckDate, true);
                RenumerationsCards.Add(new DataCard {
                    Info1 = "Heures Enseignées",
                    Info2 = StudyManager.StaticGetHoursTaught(employ.StaffGuid, payrollStart, payroll.PaycheckDate, true).TotalHoursMins(),
                    Info3 = TotalSalary.ToString("0.##", CultureInfo.CurrentCulture) + " dhs"
                });
                break;
                //case PayType.HoursWorked:
                //    TotalSalary=(payroll.HoursWorked.TotalMinutes*(employ.HourlyPay/60));
                //    RenumerationsCards.Add(new DataCard {
                //        Info1="Heures Travaillées",
                //        Info2=payroll.HoursWorked.TotalHoursMins(),
                //        Info3=TotalSalary.ToString("0.##", CultureInfo.CurrentCulture)+" dhs"
                //    });
                //    break;
            }

            foreach (var salary in PayrollManager.StaticGetSalaries(employ.EmploymentGuid, payrollStart, payroll.PaycheckDate))
            {
                RenumerationsCards.Add(new DataCard(salary));
                TotalSalary += salary.Remuneration;
            }

            if (payroll.PaycheckDate > DateTime.Today)
            {
                TotalSalaryString = "Estimation: " + TotalSalary.ToString("0.##", CultureInfo.CurrentCulture) + " dhs";
            }
            else
            {
                TotalSalaryString = "Total: " + TotalSalary.ToString("0.##", CultureInfo.CurrentCulture) + " dhs";
            }

            if (!payroll.IsPaid)
            {
                return;
            }
            TotalSalary       = payroll.FinalPaycheck;
            TotalSalaryString = "Paid: " + TotalSalary.ToString("0.##", CultureInfo.CurrentCulture) + " dhs";
            NumeroReference   = "Ref: " + payroll.NumeroReference;
            Observations      = "Finance User (" + payroll.DatePaid.GetValueOrDefault().ToShortDateString() + ")"; //+" par "+payroll.PaymentMethode.GetEnumDescription();
            YesNoColor        = "Blue";
        }
示例#11
0
 /// <summary>
 /// La nombre de salire non payer au Staff entre ces deux dates
 /// </summary>
 /// <param name="staffGuid"></param>
 /// <param name="startDate"></param>
 /// <param name="endDate"></param>
 /// <returns></returns>
 public int GetStaffTotalDue(Guid staffGuid)
 {
     using (var db = new EconomatContext())
         return
             (StaticGetEmployements(staffGuid)
              .ToList()
              .Sum(e => db.Payrolls.Count(p => p.EmploymentGuid == e.EmploymentGuid && !p.IsPaid)));
 }
示例#12
0
 /// <summary>
 /// Supprime Un Recue
 /// </summary>
 /// <param name="myReceiptGuid">Guid du Ticket</param>
 /// <returns>True pour Success</returns>
 protected internal static bool HardDeleteFeeReceipt(Guid myReceiptGuid)
 {
     using (var db = new EconomatContext())
     {
         //db.FeeReceipts.Remove(db.FeeReceipts.Find(myReceiptGuid));
         return(db.SaveChanges() > 0);
     }
 }
示例#13
0
 /// <summary>
 /// Soft Supprime Un Recue
 /// </summary>
 /// <param name="myPayOff">Guid du Ticket</param>
 /// <returns>True pour Success</returns>
 protected internal static bool DeleteFeeReceipt(BillPayOff myPayOff)
 {
     using (var db = new EconomatContext())
     {
         //db.FeeReceipts.Attach(myReceipt);
         db.Entry(myPayOff).State = EntityState.Modified;
         return(db.SaveChanges() > 0);
     }
 }
示例#14
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="studentGuid"></param>
 /// <returns></returns>
 public IEnumerable GetStudentFactures(Guid studentGuid)
 {
     using (var mc = new EconomatContext())
         return
             (mc.SchoolFees.Where(s => s.StudentGuid == studentGuid && !s.IsPaid)
              .ToList()
              .Select(schoolFee => new StudentBill(schoolFee))
              .ToList().OrderBy(f => f.DueDate));
 }
示例#15
0
 /// <summary>
 /// La Somme Payer au Staff entre ces deux dates
 /// </summary>
 /// <param name="staffGuid"></param>
 /// <param name="startDate"></param>
 /// <param name="endDate"></param>
 /// <returns></returns>
 /// <exception cref="NotImplementedException"></exception>
 public double GetStaffTotalPaid(Guid staffGuid, DateTime?startDate, DateTime?endDate)
 {
     using (var db = new EconomatContext())
         return
             (StaticGetEmployements(staffGuid, startDate, endDate)
              .Select(e => e.EmploymentGuid)
              .Where(employ => db.Payrolls.Any(e => e.EmploymentGuid == employ && e.IsPaid))
              .Sum(
                  employ =>
                  db.Payrolls.Where(e => e.EmploymentGuid == employ && e.IsPaid).Sum(p => p.FinalPaycheck)));
 }
示例#16
0
        /// <summary>
        /// Modifier un Recue
        /// </summary>
        /// <param name="myPayOff"></param>
        /// <returns>True pour Success</returns>
        protected internal static bool UpdateFeeReceipt(BillPayOff myPayOff)
        {
            //myPayement.DateEdited = DateTime.Now;

            using (var db = new EconomatContext())
            {
                //db.FeeReceipts.Attach(myReceipt);
                db.Entry(myPayOff).State = EntityState.Modified;
                return(db.SaveChanges() > 0);
            }
        }
示例#17
0
        /// <summary>
        /// Modifier les information d'un salaire
        /// </summary>
        /// <param name="salary"></param>
        /// <exception cref="NotImplementedException"></exception>
        public bool CancelSalary(Salary salary)
        {
            if (string.IsNullOrEmpty(salary.Designation))
            {
                throw new InvalidOperationException("DESIGNATION_CAN_NOT_BE_EMPTY");
            }
            if (salary.StartDate > salary.EndDate)
            {
                throw new InvalidOperationException("START_DATE_SUPERIOR_TO_END_DATE");
            }
            if (salary.EndDate < DateTime.Today)
            {
                throw new InvalidOperationException("END_DATE_CAN_NOT_BE_LESS_THAN_TODAY");
            }

            Employment emp;

            using (var db = new EconomatContext()) emp = db.Employments.Find(salary.EmploymentGuid);
            if (emp == null)
            {
                throw new InvalidOperationException("EMPLOYEMENT_REFERENCE_NOT_FOUND");
            }
            if ((salary.StartDate < emp.StartDate) || (salary.EndDate > emp.EndDate))
            {
                throw new InvalidOperationException("DATES_CAN_NOT_BE_OUT_OF_EMPLOYMENT_BOUNDRIES");
            }

            using (var db = new EconomatContext())
            {
                var newSalary = db.Salaries.Find(salary.SalaryGuid);
                if (newSalary == null)
                {
                    throw new InvalidOperationException("SALARY_REFERENCE_NOT_FOUND");
                }

                newSalary.EndDate     = salary.EndDate;
                newSalary.Description = salary.Description;

                var user = Membership.GetUser();
                if (user == null)
                {
                    throw new SecurityException("USER_CAN_NOT_DETERMINED");
                }

                // ReSharper disable once PossibleNullReferenceException
                newSalary.LastEditUserGuid = (Guid)user.ProviderUserKey;
                newSalary.LastEditDate     = DateTime.Now;

                db.Salaries.Attach(newSalary);
                db.Entry(newSalary).State = EntityState.Modified;
                return(db.SaveChanges() > 0);
            }
        }
示例#18
0
        /// <summary>
        /// Les Informtions d'une renumeration
        /// </summary>
        /// <param name="salary"></param>
        public SalaryCard(Salary salary)
        {
            SalaryGuid   = salary.SalaryGuid;
            Denomination = salary.Designation;

            Description = salary.Remuneration + " dhs (";
            using (var db = new EconomatContext()) Description += db.Employments.Find(salary.EmploymentGuid).SalaryRecurrence.GetEnumDescription() + ")";

            DateString = salary.StartDate.GetValueOrDefault().ToShortDateString() + " -> " +
                         salary.EndDate.GetValueOrDefault().ToShortDateString();

            IsExpiredColor = salary.EndDate.GetValueOrDefault() < DateTime.Today ? "Beige" : "LightGray";
        }
示例#19
0
        /// <summary>
        /// Return La List des etudiants avec facture non payer
        /// </summary>
        /// <returns></returns>
        public IEnumerable GetStudentWithDebt()
        {
            using (var mc = new EconomatContext())
            {
                var studentMiniCard = new List <SearchCard>();
                var guidList        = mc.SchoolFees.Where(s => !s.IsPaid).Select(f => f.StudentGuid).Distinct();

                foreach (var guid in guidList)
                {
                    studentMiniCard.Add(new SearchCard(guid));
                }
                return(studentMiniCard);
            }
        }
示例#20
0
        /// <summary>
        /// Verifie L'existence d'une payroll
        /// </summary>
        /// <param name="payroll"></param>
        /// <returns>True pour oui</returns>
        protected internal static bool PayRollExist(Payroll payroll)
        {
            using (var db = new EconomatContext())
            {
                if (db.Payrolls.Find(payroll.PayrollGuid) != null)
                {
                    return(true);
                }

                return(db.Payrolls.Any(r => r.EmploymentGuid == payroll.EmploymentGuid &&
                                       r.Designation.Equals(payroll.Designation) &&
                                       r.PaycheckDate == payroll.PaycheckDate));
            }
        }
示例#21
0
        /// <summary>
        /// AllGrades
        /// </summary>
        /// <returns></returns>
        public IEnumerable AllGrades()
        {
            using (var db = new EconomatContext())
            {
                var pos = (from s in db.Employments.ToList() where !string.IsNullOrEmpty(s.Grade) select s.Grade).Distinct().ToList();

                return(!pos.Any()
                    ? new List <string>
                {
                    "Senior",
                    "Junior"
                }
                    : pos);
            }
        }
示例#22
0
        /// <summary>
        /// Verifie L'existence d'un Recue
        /// </summary>
        /// <param name="myBill"></param>
        /// <returns>True pour oui</returns>
        protected internal static bool FeeReceiptExist(StudentBill myBill)
        {
            using (var db = new EconomatContext())
            {
                if (db.SchoolFees.Find(myBill.SchoolFeeGuid) != null)
                {
                    return(true);
                }

                return(db.SchoolFees.Any(r => r.StudentGuid == myBill.StudentGuid &&
                                         r.Designation.Equals(myBill.Designation) &&
                                         r.DueDate == myBill.DueDate &&
                                         Math.Abs(r.NetAmount - myBill.NetAmount) < .00001));
            }
        }
示例#23
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="salary"></param>
        /// <returns></returns>
        protected internal static bool StaticAddSalary(Salary salary)
        {
            if (SalaryExist(salary))
            {
                return(true);
            }
            if (string.IsNullOrEmpty(salary.Designation))
            {
                throw new InvalidOperationException("DESIGNATION_CAN_NOT_BE_EMPTY");
            }
            if (salary.StartDate > salary.EndDate)
            {
                throw new InvalidOperationException("START_DATE_SUPERIOR_TO_END_DATE");
            }

            Employment emp;

            using (var db = new EconomatContext()) emp = db.Employments.Find(salary.EmploymentGuid);

            if (emp == null)
            {
                throw new InvalidOperationException("EMPLOYEMENT_REFERENCE_NOT_FOUND");
            }
            if ((salary.StartDate < emp.StartDate) || (salary.EndDate > emp.EndDate))
            {
                throw new InvalidOperationException("DATES_CAN_NOT_BE_OUT_OF_EMPLOYMENT_BOUNDRIES");
            }

            using (var db = new EconomatContext())
            {
                if (salary.SalaryGuid == Guid.Empty)
                {
                    salary.SalaryGuid = Guid.NewGuid();
                }
                if (salary.Description == string.Empty)
                {
                    salary.Description = salary.Designation;
                }

                salary.DateAdded        = DateTime.Now;
                salary.AddUserGuid      = Guid.Empty;
                salary.LastEditDate     = DateTime.Now;
                salary.LastEditUserGuid = Guid.Empty;

                db.Salaries.Add(salary);
                return(db.SaveChanges() > 0);
            }
        }
示例#24
0
        /// <summary>
        /// Verifie L'existence d'une Salaire
        /// </summary>
        /// <param name="salary"></param>
        /// <returns>True pour oui</returns>
        protected internal static bool SalaryExist(Salary salary)
        {
            using (var db = new EconomatContext())
            {
                if (db.Salaries.Find(salary.SalaryGuid) != null)
                {
                    return(true);
                }

                return(db.Salaries.Any(r => r.EmploymentGuid == salary.EmploymentGuid &&
                                       r.Designation.Equals(salary.Designation) &&
                                       r.StartDate == salary.StartDate &&
                                       r.EndDate == salary.EndDate &&
                                       Math.Abs(r.Remuneration - salary.Remuneration) < .001));
            }
        }
示例#25
0
        /// <summary>
        /// AllProjets
        /// </summary>
        /// <returns></returns>
        public IEnumerable AllProjets()
        {
            using (var db = new EconomatContext())
            {
                var pos = (from s in db.Employments.ToList() where !string.IsNullOrEmpty(s.Project) select s.Project).Distinct().ToList();

                return(!pos.Any()
                    ? new List <string>
                {
                    "Recherche Marché",
                    "Alpha 1",
                    "XKeyscore"
                }
                    : pos);
            }
        }
示例#26
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="employGuid"></param>
        /// <param name="startDate"></param>
        /// <param name="endDate"></param>
        /// <returns></returns>
        protected internal static List <Payroll> StaticGetPayrolls(Guid employGuid, DateTime?startDate = null, DateTime?endDate = null)
        {
            using (var db = new EconomatContext()) {
                if (startDate == null || endDate == null)
                {
                    return(db.Payrolls.Where(e => e.EmploymentGuid == employGuid).OrderByDescending(e => e.PaycheckDate).ToList());
                }

                return(db.Payrolls.Where(
                           e => e.EmploymentGuid == employGuid &&
                           (
                               e.PaycheckDate >= startDate &&
                               e.PaycheckDate <= endDate
                           )).OrderByDescending(e => e.PaycheckDate).ToList());
            }
        }
示例#27
0
        /// <summary>
        /// AllDivisions
        /// </summary>
        /// <returns></returns>
        public IEnumerable AllDivisions()
        {
            using (var db = new EconomatContext())
            {
                var pos = (from s in db.Employments.ToList() where !string.IsNullOrEmpty(s.Division) select s.Division).Distinct().ToList();

                return(!pos.Any()
                    ? new List <string>
                {
                    "Marketing",
                    "Finance",
                    "Recherche"
                }
                    : pos);
            }
        }
示例#28
0
        /// <summary>
        /// Return La liste des salairs d'un Employements
        /// </summary>
        /// <param name="employGuid"></param>
        /// <param name="startDate"></param>
        /// <param name="endDate"></param>
        /// <returns></returns>
        protected internal static List <Salary> StaticGetSalaries(Guid employGuid, DateTime?startDate = null, DateTime?endDate = null)
        {
            using (var db = new EconomatContext())
            {
                if (startDate == null || endDate == null)
                {
                    return(db.Salaries.Where(e => e.EmploymentGuid == employGuid).OrderByDescending(e => e.StartDate).ToList());
                }

                return(db.Salaries.Where(
                           e => e.EmploymentGuid == employGuid &&
                           (
                               e.StartDate <= endDate &&
                               e.EndDate >= endDate
                           )).OrderBy(e => e.StartDate).ToList());
            }
        }
示例#29
0
        /// <summary>
        /// Modifier les information d'un employement
        /// </summary>
        /// <param name="employ"></param>
        /// <returns></returns>
        /// <exception cref="NotImplementedException"></exception>
        public bool UpdateEmployment(Employment employ)
        {
            if (string.IsNullOrEmpty(employ.Position))
            {
                throw new InvalidOperationException("POSITION_CAN_NOT_BE_EMPTY");
            }
            if (employ.StartDate > employ.EndDate)
            {
                throw new InvalidOperationException("START_DATE_SUPERIOR_TO_END_DATE");
            }
            using (var db = new SchoolContext()) if (db.Staffs.Find(employ.StaffGuid) == null)
                {
                    throw new InvalidOperationException("STAFF_REFERENCE_NOT_FOUND");
                }

            using (var db = new EconomatContext())
            {
                var newEmploy = db.Employments.Find(employ.EmploymentGuid);
                if (newEmploy == null)
                {
                    throw new InvalidOperationException("EMPLOYEMENT_REFERENCE_NOT_FOUND");
                }

                //todo cancel Employ
                newEmploy.Position    = employ.Position;
                newEmploy.Category    = employ.Category;
                newEmploy.Project     = employ.Project;
                newEmploy.Grade       = employ.Grade;
                newEmploy.Departement = employ.Departement;
                newEmploy.Division    = employ.Division;
                newEmploy.ReportTo    = employ.ReportTo;
                //newEmploy.SalaryRecurrence = employ.SalaryRecurrence;
                //newEmploy.StartDate        = employ.StartDate;
                //newEmploy.EndDate          = employ.EndDate;
                newEmploy.Description = employ.Description;

                newEmploy.LastEditDate     = DateTime.Now;
                newEmploy.LastEditUserGuid = Guid.Empty;

                db.Employments.Attach(newEmploy);
                db.Entry(newEmploy).State = EntityState.Modified;

                return(db.SaveChanges() > 0);
            }
        }
示例#30
0
        /// <summary>
        /// AllCategories
        /// </summary>
        /// <returns></returns>
        public IEnumerable AllCategories()
        {
            using (var db = new EconomatContext())
            {
                var pos = (from s in db.Employments.ToList() where !string.IsNullOrEmpty(s.Category) select s.Category).Distinct().ToList();

                return(!pos.Any()
                    ? new List <string>
                {
                    "Full Time",
                    "Temps Plein",
                    "contracteur",
                    "Temps Partiel",
                    "Part Time"
                }
                    : pos);
            }
        }