Beispiel #1
0
        public HttpResponseMessage CreateOverTimeDetail(OverTimesViewModel OverTimeVM)
        {
            List <OverTimesDetailsBLL> OverTimeEmployeesList = GetOverTimeDetailsFromSession();

            if (string.IsNullOrEmpty(OverTimeVM.OverTimeDetailRequest.EmployeeCareerHistory.EmployeeCode.EmployeeCodeNo))
            {
                throw new CustomException(Resources.Globalization.RequiredEmployeeCodeNoText);
            }
            else if (OverTimeEmployeesList.FindIndex(e => e.EmployeeCareerHistory.EmployeeCode.EmployeeCodeNo.Equals(OverTimeVM.OverTimeDetailRequest.EmployeeCareerHistory.EmployeeCode.EmployeeCodeNo)) > -1)
            {
                throw new CustomException(Resources.Globalization.ValidationEmployeeAlreadyExistText);
            }

            DateTime StartDate, EndDate;

            StartDate = OverTimeVM.OverTimeStartDate;
            EndDate   = (DateTime)OverTimeVM.OverTimeEndDate;

            OverTimesBLL overtime = new OverTimesBLL()
            {
                OverTimeStartDate = StartDate,
                OverTimeEndDate   = EndDate,
                OverTimesDays     = GetOverTimeDays(OverTimeVM.OverTimesDays)
            };

            Result result = new OverTimesDetailsBLL()
            {
                OverTime = overtime,
                EmployeeCareerHistory = new EmployeesCareersHistoryBLL()
                {
                    EmployeeCareerHistoryID = OverTimeVM.OverTimeDetailRequest.EmployeeCareerHistory.EmployeeCareerHistoryID,
                    EmployeeCode            = new EmployeesCodesBLL()
                    {
                        EmployeeCodeID = OverTimeVM.OverTimeDetailRequest.EmployeeCareerHistory.EmployeeCode.EmployeeCodeID
                    }
                }
            }.IsValid();

            if (result.EnumMember == OverTimeValidationEnum.Done.ToString())
            {
                OverTimeEmployeesList.Add(OverTimeVM.OverTimeDetailRequest);
                Session["OverTimesEmployees"] = OverTimeEmployeesList;
            }
            else if (result.EnumMember == OverTimeValidationEnum.RejectedBecauseOfOverTimeDatesMustBeInSameFinancialYear.ToString())
            {
                FinancialYearsBLL FinancialYearBLL = (FinancialYearsBLL)result.Entity;
                throw new CustomException(Resources.Globalization.ValidationOverTimeDatesMustBeInSameFinancialYearText + " NewLine " +
                                          Resources.Globalization.FinancialYearInfoText + FinancialYearBLL.FinancialYear + " NewLine " +
                                          Resources.Globalization.FinancialYearStartDateText + FinancialYearBLL.FinancialYearStartDate.Date.ToString(System.Configuration.ConfigurationManager.AppSettings["DateFormat"]) + " NewLine " +
                                          Resources.Globalization.FinancialYearEndDateText + FinancialYearBLL.FinancialYearEndDate.Date.ToString(System.Configuration.ConfigurationManager.AppSettings["DateFormat"]));
            }
            Classes.Helpers.CommonHelper.ConflictValidationMessage(result);

            return(new HttpResponseMessage(HttpStatusCode.OK));
        }
Beispiel #2
0
        public HttpResponseMessage CreateOverTimeDetailDB(OverTimesViewModel OverTimeVM)
        {
            if (string.IsNullOrEmpty(OverTimeVM.OverTimeDetailRequest.EmployeeCareerHistory.EmployeeCode.EmployeeCodeNo))
            {
                throw new CustomException(Resources.Globalization.RequiredEmployeeCodeNoText);
            }

            DateTime StartDate, EndDate;

            StartDate = OverTimeVM.OverTimeStartDate;
            EndDate   = (DateTime)OverTimeVM.OverTimeEndDate;
            OverTimesBLL overtime = new OverTimesBLL()
            {
                OverTimeID = OverTimeVM.OverTimeID, OverTimeStartDate = OverTimeVM.OverTimeStartDate, OverTimeEndDate = (DateTime)OverTimeVM.OverTimeEndDate
            };

            OverTimesDetailsBLL overTimesDetail = new OverTimesDetailsBLL()
            {
                OverTime = overtime,
                EmployeeCareerHistory = new EmployeesCareersHistoryBLL()
                {
                    EmployeeCareerHistoryID = OverTimeVM.OverTimeDetailRequest.EmployeeCareerHistory.EmployeeCareerHistoryID,
                    EmployeeCode            = new EmployeesCodesBLL()
                    {
                        EmployeeCodeID = OverTimeVM.OverTimeDetailRequest.EmployeeCareerHistory.EmployeeCode.EmployeeCodeID
                    }
                },
                LoginIdentity = new EmployeesCodesBLL()
                {
                    EmployeeCodeID = int.Parse(Session["EmployeeCodeID"].ToString())
                }
            };
            Result result = overTimesDetail.IsValid();

            if (result.EnumMember == OverTimeValidationEnum.Done.ToString())
            {
                result = new OverTimesDetailsBLL().Add(overTimesDetail);
            }
            else if (result.EnumMember == OverTimeValidationEnum.RejectedBecauseOfOverTimeDatesMustBeInSameFinancialYear.ToString())
            {
                FinancialYearsBLL FinancialYearBLL = (FinancialYearsBLL)result.Entity;
                throw new CustomException(Resources.Globalization.ValidationOverTimeDatesMustBeInSameFinancialYearText + "NewLine" +
                                          Resources.Globalization.FinancialYearInfoText + FinancialYearBLL.FinancialYear + ": NewLine" +
                                          Resources.Globalization.FinancialYearStartDateText + FinancialYearBLL.FinancialYearStartDate.Date.ToString(System.Configuration.ConfigurationManager.AppSettings["DateFormat"]) + "NewLine" +
                                          Resources.Globalization.FinancialYearEndDateText + FinancialYearBLL.FinancialYearEndDate.Date.ToString(System.Configuration.ConfigurationManager.AppSettings["DateFormat"]));
            }
            else if (result.EnumMember == OverTimeValidationEnum.RejectedBecauseAlreadyExist.ToString())
            {
                throw new CustomException(Resources.Globalization.ValidationEmployeeAlreadyExistText);
            }
            Classes.Helpers.CommonHelper.ConflictValidationMessage(result);

            return(new HttpResponseMessage(HttpStatusCode.OK));
        }
Beispiel #3
0
        public HttpResponseMessage CreateDelegationDetail(DelegationsViewModel DelegationVM)
        {
            List <DelegationsDetailsBLL> DelegationEmployeesList = GetDelegationDetailsFromSession();

            if (string.IsNullOrEmpty(DelegationVM.DelegationDetailRequest.EmployeeCareerHistory.EmployeeCode.EmployeeCodeNo))
            {
                throw new CustomException(Resources.Globalization.RequiredEmployeeCodeNoText);
            }
            else if (DelegationEmployeesList.FindIndex(e => e.EmployeeCareerHistory.EmployeeCode.EmployeeCodeNo.Equals(DelegationVM.DelegationDetailRequest.EmployeeCareerHistory.EmployeeCode.EmployeeCodeNo)) > -1)
            {
                throw new CustomException(Resources.Globalization.ValidationEmployeeAlreadyExistText);
            }

            DateTime StartDate, EndDate;

            StartDate = DelegationVM.DelegationStartDate;
            EndDate   = DelegationVM.DelegationEndDate;

            Result result = new EmployeeDelegationBLL(StartDate, EndDate, DelegationVM.DelegationKind.DelegationKindID, new EmployeesCodesBLL()
            {
                EmployeeCodeID = DelegationVM.DelegationDetailRequest.EmployeeCareerHistory.EmployeeCode.EmployeeCodeID
            }).IsValid();

            //if ((System.Type)result.EnumType == typeof(DelegationsValidationEnum))
            //{
            if (result.EnumMember == DelegationsValidationEnum.Done.ToString())
            {
                DelegationEmployeesList.Add(DelegationVM.DelegationDetailRequest);
                Session["DelegationsEmployees"] = DelegationEmployeesList;
            }
            else if (result.EnumMember == DelegationsValidationEnum.RejectedBecauseOfDelegationDatesMustBeInSameFinancialYear.ToString())
            {
                FinancialYearsBLL FinancialYearBLL = (FinancialYearsBLL)result.Entity;
                throw new CustomException(Resources.Globalization.ValidationDelegationDatesMustBeInSameFinancialYearText + " NewLine" +
                                          Resources.Globalization.FinancialYearInfoText + FinancialYearBLL.FinancialYear + " NewLine" +
                                          Resources.Globalization.FinancialYearStartDateText + FinancialYearBLL.FinancialYearStartDate.Date.ToString(Classes.Helpers.CommonHelper.DateFormat) + " NewLine" +
                                          Resources.Globalization.FinancialYearEndDateText + FinancialYearBLL.FinancialYearEndDate.Date.ToString(Classes.Helpers.CommonHelper.DateFormat));
            }
            else if (result.EnumMember == DelegationsValidationEnum.RejectedBecauseOfMaxLimit.ToString())
            {
                throw new CustomException(Resources.Globalization.ValidationAlreadyReachTheDelegationLimitText);
            }
            Classes.Helpers.CommonHelper.ConflictValidationMessage(result);
            //else if (result.EnumMember == NoConflictWithOtherProcessValidationEnum.RejectedBecauseOfConflictWithOverTime.ToString())
            //{
            //    throw new CustomException(Resources.Globalization.ValidationConflictWithOverTimeText);
            //}
            //else if (result.EnumMember == NoConflictWithOtherProcessValidationEnum.RejectedBecauseOfConflictWithDelegation.ToString())
            //{
            //    throw new CustomException(Resources.Globalization.ValidationConflictWithDelegationText);
            //}
            //else if (result.EnumMember == NoConflictWithOtherProcessValidationEnum.RejectedBecauseOfConflictWithInternshipScholarship.ToString())
            //{
            //    throw new CustomException(Resources.Globalization.ValidationConflictWithInternshipScholarshipText);
            //}
            //else if (result.EnumMember == NoConflictWithOtherProcessValidationEnum.RejectedBecauseOfConflictWithVacation.ToString())
            //{
            //    throw new CustomException(Resources.Globalization.ValidationConflictWithVacationText);
            //}
            //}
            return(new HttpResponseMessage(HttpStatusCode.OK));
        }
Beispiel #4
0
        public ActionResult Create(DelegationsViewModel DelegationVM)
        {
            if (DelegationVM.DelegationType.DelegationTypeID == (Int32)DelegationsTypesEnum.Internal)
            {
                InternalDelegationBLL Delegation = new InternalDelegationBLL();
                Delegation.DelegationKind = new DelegationsKindsBLL()
                {
                    DelegationKindID = DelegationVM.DelegationKind.DelegationKindID
                };
                Delegation.DelegationType = new DelegationsTypesBLL()
                {
                    DelegationTypeID = (int)DelegationsTypesEnum.Internal
                };
                Delegation.DelegationStartDate = DelegationVM.DelegationStartDate;
                Delegation.DelegationEndDate   = DelegationVM.DelegationEndDate;
                Delegation.DelegationReason    = DelegationVM.DelegationReason;
                Delegation.Notes   = DelegationVM.Notes;
                Delegation.KSACity = new KSACitiesBLL()
                {
                    KSACityID = DelegationVM.KSACity.KSACityID
                };
                Delegation.DelegationDistancePeriod = DelegationVM.DelegationDistancePeriod;
                Delegation.LoginIdentity            = UserIdentity;
                Delegation.DelegationsDetails       = GetDelegationDetailsFromSession();
                Result result = Delegation.Add();

                BaseDelegationsBLL DelegationEntity = (BaseDelegationsBLL)result.Entity;
                if (result.EnumMember == DelegationsValidationEnum.Done.ToString())
                {
                    DelegationVM.DelegationID = ((InternalDelegationBLL)result.Entity).DelegationID;
                    ClearDelegationDetailsFromSession();
                }
                else if (result.EnumMember == DelegationsValidationEnum.RejectedBecauseOfDelegationDatesMustBeInSameFinancialYear.ToString())
                {
                    FinancialYearsBLL FinancialYearBLL = (FinancialYearsBLL)result.Entity;
                    throw new CustomException(Resources.Globalization.ValidationDelegationDatesMustBeInSameFinancialYearText + " NewLine" +
                                              Resources.Globalization.FinancialYearInfoText + FinancialYearBLL.FinancialYear + " NewLine" +
                                              Resources.Globalization.FinancialYearStartDateText + FinancialYearBLL.FinancialYearStartDate.Date.ToString(Classes.Helpers.CommonHelper.DateFormat) + " NewLine" +
                                              Resources.Globalization.FinancialYearEndDateText + FinancialYearBLL.FinancialYearEndDate.Date.ToString(Classes.Helpers.CommonHelper.DateFormat));
                }
                else if (result.EnumMember == DelegationsValidationEnum.RejectedBecauseOfMaxLimit.ToString())
                {
                    throw new CustomException(Resources.Globalization.ValidationAlreadyReachTheDelegationLimitText);
                }
                else if (result.EnumMember == DelegationsValidationEnum.RejectedBecauseEmployeeRequired.ToString())
                {
                    throw new CustomException(Resources.Globalization.ValidationEmployeeRequiredText);
                }

                Classes.Helpers.CommonHelper.ConflictValidationMessage(result);
            }
            else if (DelegationVM.DelegationType.DelegationTypeID == (Int32)DelegationsTypesEnum.External)
            {
                ExternalDelegationBLL Delegation = new ExternalDelegationBLL();
                Delegation.DelegationKind = new DelegationsKindsBLL()
                {
                    DelegationKindID = DelegationVM.DelegationKind.DelegationKindID
                };
                Delegation.DelegationType = new DelegationsTypesBLL()
                {
                    DelegationTypeID = (int)DelegationsTypesEnum.External
                };
                Delegation.DelegationStartDate = DelegationVM.DelegationStartDate;
                Delegation.DelegationEndDate   = DelegationVM.DelegationEndDate;
                Delegation.DelegationReason    = DelegationVM.DelegationReason;
                Delegation.Notes = DelegationVM.Notes;
                Delegation.DelegationDistancePeriod = DelegationVM.DelegationDistancePeriod;
                Delegation.LoginIdentity            = UserIdentity;
                Delegation.Country = new CountriesBLL()
                {
                    CountryID = DelegationVM.Country.CountryID
                };
                Delegation.DelegationsDetails = GetDelegationDetailsFromSession();
                Result result = Delegation.Add();
                //if ((System.Type)result.EnumType == typeof(DelegationsValidationEnum))
                //{
                BaseDelegationsBLL DelegationEntity = (BaseDelegationsBLL)result.Entity;
                if (result.EnumMember == DelegationsValidationEnum.Done.ToString())
                {
                    DelegationVM.DelegationID = ((ExternalDelegationBLL)result.Entity).DelegationID;
                    ClearDelegationDetailsFromSession();
                }
                else if (result.EnumMember == DelegationsValidationEnum.RejectedBecauseOfDelegationDatesMustBeInSameFinancialYear.ToString())
                {
                    FinancialYearsBLL FinancialYearBLL = (FinancialYearsBLL)result.Entity;
                    throw new CustomException(Resources.Globalization.ValidationDelegationDatesMustBeInSameFinancialYearText + " NewLine" +
                                              Resources.Globalization.FinancialYearInfoText + FinancialYearBLL.FinancialYear + " NewLine" +
                                              Resources.Globalization.FinancialYearStartDateText + FinancialYearBLL.FinancialYearStartDate.Date.ToString(Classes.Helpers.CommonHelper.DateFormat) + " NewLine" +
                                              Resources.Globalization.FinancialYearEndDateText + FinancialYearBLL.FinancialYearEndDate.Date.ToString(Classes.Helpers.CommonHelper.DateFormat));
                }
                else if (result.EnumMember == DelegationsValidationEnum.RejectedBecauseOfMaxLimit.ToString())
                {
                    throw new CustomException(Resources.Globalization.ValidationAlreadyReachTheDelegationLimitText);
                }
                else if (result.EnumMember == DelegationsValidationEnum.RejectedBecauseEmployeeRequired.ToString())
                {
                    throw new CustomException(Resources.Globalization.ValidationEmployeeRequiredText);
                }

                Classes.Helpers.CommonHelper.ConflictValidationMessage(result);
            }

            return(Json(new { DelegationID = DelegationVM.DelegationID }, JsonRequestBehavior.AllowGet));
        }