public HttpResponseMessage RemoveEmployeeFromInternshipScholarship(InternshipScholarshipsViewModel InternshipScholarshipVM)
        {
            List <InternshipScholarshipsDetailsBLL> InternshipScholarshipEmployeesList = GetInternshipScholarshipDetailsFromSession();

            InternshipScholarshipEmployeesList.RemoveAt(InternshipScholarshipEmployeesList.FindIndex(e => e.EmployeeCareerHistory.EmployeeCode.EmployeeCodeNo.Equals(InternshipScholarshipVM.InternshipScholarshipDetailRequest.EmployeeCareerHistory.EmployeeCode.EmployeeCodeNo)));
            return(new HttpResponseMessage(HttpStatusCode.OK));
        }
        private InternshipScholarshipsViewModel GetByInternshipScholarshipID(int id)
        {
            BaseInternshipScholarshipsBLL   InternshipScholarshipBLL = new BaseInternshipScholarshipsBLL().GetByInternshipScholarshipID(id);
            InternshipScholarshipsViewModel InternshipScholarshipVM  = new InternshipScholarshipsViewModel();

            if (InternshipScholarshipBLL != null)
            {
                if (InternshipScholarshipBLL.InternshipScholarshipType.InternshipScholarshipTypeID == (Int32)InternshipScholarshipsTypesEnum.Internal)
                {
                    InternshipScholarshipVM.KSARegion = ((InternalInternshipScholarshipsBLL)InternshipScholarshipBLL).KSACity.KSARegion;
                    InternshipScholarshipVM.KSACity   = ((InternalInternshipScholarshipsBLL)InternshipScholarshipBLL).KSACity;
                }
                else if (InternshipScholarshipBLL.InternshipScholarshipType.InternshipScholarshipTypeID == (Int32)InternshipScholarshipsTypesEnum.External)
                {
                    InternshipScholarshipVM.Country = ((ExternalInternshipScholarshipsBLL)InternshipScholarshipBLL).Country;
                }

                InternshipScholarshipVM.InternshipScholarshipType = new InternshipScholarshipsTypesBLL()
                {
                    InternshipScholarshipTypeID = InternshipScholarshipBLL.InternshipScholarshipType.InternshipScholarshipTypeID, InternshipScholarshipTypeName = InternshipScholarshipBLL.InternshipScholarshipType.InternshipScholarshipTypeName
                };
                InternshipScholarshipVM.InternshipScholarshipID        = InternshipScholarshipBLL.InternshipScholarshipID;
                InternshipScholarshipVM.InternshipScholarshipStartDate = InternshipScholarshipBLL.InternshipScholarshipStartDate.Date;
                InternshipScholarshipVM.InternshipScholarshipEndDate   = InternshipScholarshipBLL.InternshipScholarshipEndDate;
                InternshipScholarshipVM.InternshipScholarshipReason    = InternshipScholarshipBLL.InternshipScholarshipReason;
                InternshipScholarshipVM.InternshipScholarshipPeriod    = InternshipScholarshipBLL.InternshipScholarshipPeriod;
                InternshipScholarshipVM.InternshipScholarshipLocation  = InternshipScholarshipBLL.InternshipScholarshipLocation;
                InternshipScholarshipVM.CreatedDate = InternshipScholarshipBLL.CreatedDate;
                InternshipScholarshipVM.CreatedBy   = InternshipScholarshipVM.GetCreatedByDisplayed(InternshipScholarshipBLL.CreatedBy);
            }
            return(InternshipScholarshipVM);
        }
        public ActionResult Delete(InternshipScholarshipsViewModel InternshipScholarshipVM)
        {
            BaseInternshipScholarshipsBLL baseInternshipScholarshipsBLL = new BaseInternshipScholarshipsBLL();

            baseInternshipScholarshipsBLL.LoginIdentity = UserIdentity;
            baseInternshipScholarshipsBLL.Remove(InternshipScholarshipVM.InternshipScholarshipID);
            //return View(InternshipScholarshipVM);
            return(RedirectToAction("Index"));
        }
        public HttpResponseMessage CreateInternshipScholarshipDetail(InternshipScholarshipsViewModel InternshipScholarshipVM)
        {
            List <InternshipScholarshipsDetailsBLL> InternshipScholarshipEmployeesList = GetInternshipScholarshipDetailsFromSession();

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

            DateTime StartDate, EndDate;

            StartDate = InternshipScholarshipVM.InternshipScholarshipStartDate;
            EndDate   = InternshipScholarshipVM.InternshipScholarshipEndDate;

            Result result = CommonHelper.IsNoConflictWithOtherProcess(InternshipScholarshipVM.InternshipScholarshipDetailRequest.EmployeeCareerHistory.EmployeeCode.EmployeeCodeID, StartDate, EndDate);

            if (result == null)
            {
                InternshipScholarshipEmployeesList.Add(InternshipScholarshipVM.InternshipScholarshipDetailRequest);
                Session["InternshipScholarshipsEmployees"] = InternshipScholarshipEmployeesList;
            }
            else
            {
                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));
        }
        public HttpResponseMessage CreateInternshipScholarshipDetailDB(InternshipScholarshipsViewModel InternshipScholarshipVM)
        {
            if (string.IsNullOrEmpty(InternshipScholarshipVM.InternshipScholarshipDetailRequest.EmployeeCareerHistory.EmployeeCode.EmployeeCodeNo))
            {
                throw new CustomException(Resources.Globalization.RequiredEmployeeCodeNoText);
            }

            Result result = new InternshipScholarshipsDetailsBLL().Add(new InternshipScholarshipsDetailsBLL()
            {
                LoginIdentity = new EmployeesCodesBLL()
                {
                    EmployeeCodeID = int.Parse(Session["EmployeeCodeID"].ToString())
                },
                EmployeeCareerHistory = InternshipScholarshipVM.InternshipScholarshipDetailRequest.EmployeeCareerHistory,
                //EmployeeCode = InternshipScholarshipVM.InternshipScholarshipDetailRequest.EmployeeCareerHistory.EmployeeCode,
                InternshipScholarship = new BaseInternshipScholarshipsBLL()
                {
                    InternshipScholarshipID        = InternshipScholarshipVM.InternshipScholarshipID,
                    InternshipScholarshipStartDate = InternshipScholarshipVM.InternshipScholarshipStartDate,
                    InternshipScholarshipEndDate   = InternshipScholarshipVM.InternshipScholarshipEndDate,
                    InternshipScholarshipLocation  = InternshipScholarshipVM.InternshipScholarshipLocation,
                    InternshipScholarshipReason    = InternshipScholarshipVM.InternshipScholarshipReason,
                },
                IsPassengerOrderCompensation = InternshipScholarshipVM.InternshipScholarshipDetailRequest.IsPassengerOrderCompensation
            });

            if (result.EnumMember == InternshipScholarshipsValidationEnum.RejectedBecauseAlreadyExist.ToString())
            {
                throw new CustomException(Resources.Globalization.ValidationEmployeeAlreadyExistText);
            }
            //else if (result.EnumMember == InternshipScholarshipsValidationEnum.RejectedBecauseOfMaxLimit.ToString())
            //{
            //    throw new CustomException(Resources.Globalization.ValidationAlreadyReachTheInternshipScholarshipLimitText);
            //}
            //else if (result.EnumMember == InternshipScholarshipsValidationEnum.RejectedBecauseOfConflictWithOverTime.ToString())
            //{
            //    throw new CustomException(Resources.Globalization.ValidationInternshipScholarshipConflictWithOverTimeText);
            //}
            //else if (result.EnumMember == InternshipScholarshipsValidationEnum.RejectedBecauseOfConflictWithInternshipScholarship.ToString())
            //{
            //    throw new CustomException(Resources.Globalization.ValidationInternshipScholarshipConflictWithInternshipScholarshipText);
            //}

            return(new HttpResponseMessage(HttpStatusCode.OK));
        }
        public ActionResult Create(InternshipScholarshipsViewModel InternshipScholarshipVM)
        {
            if (InternshipScholarshipVM.InternshipScholarshipType.InternshipScholarshipTypeID == (Int32)InternshipScholarshipsTypesEnum.Internal)
            {
                InternalInternshipScholarshipsBLL InternshipScholarship = new InternalInternshipScholarshipsBLL();
                InternshipScholarship.InternshipScholarshipType = new InternshipScholarshipsTypesBLL()
                {
                    InternshipScholarshipTypeID = (int)InternshipScholarshipsTypesEnum.Internal
                };
                InternshipScholarship.InternshipScholarshipStartDate = InternshipScholarshipVM.InternshipScholarshipStartDate;
                InternshipScholarship.InternshipScholarshipEndDate   = InternshipScholarshipVM.InternshipScholarshipEndDate;
                InternshipScholarship.InternshipScholarshipReason    = InternshipScholarshipVM.InternshipScholarshipReason;
                InternshipScholarship.KSACity = new KSACitiesBLL()
                {
                    KSACityID = InternshipScholarshipVM.KSACity.KSACityID
                };
                InternshipScholarship.InternshipScholarshipLocation = InternshipScholarshipVM.InternshipScholarshipLocation;
                InternshipScholarship.LoginIdentity = UserIdentity;
                InternshipScholarship.InternshipScholarshipsDetails = GetInternshipScholarshipDetailsFromSession();
                Result result = InternshipScholarship.Add();

                BaseInternshipScholarshipsBLL InternshipScholarshipEntity = (BaseInternshipScholarshipsBLL)result.Entity;
                if (result.EnumMember == InternshipScholarshipsValidationEnum.Done.ToString())
                {
                    InternshipScholarshipVM.InternshipScholarshipID = ((InternalInternshipScholarshipsBLL)result.Entity).InternshipScholarshipID;
                    //Session["InternshipScholarshipID"] = ((InternalInternshipScholarshipsBLL)result.Entity).InternshipScholarshipID;
                    ClearInternshipScholarshipDetailsFromSession();
                }
                else if (result.EnumMember == InternshipScholarshipsValidationEnum.RejectedBecauseEmployeeRequired.ToString())
                {
                    throw new CustomException(Resources.Globalization.ValidationEmployeeRequiredText);
                }
                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 (InternshipScholarshipVM.InternshipScholarshipType.InternshipScholarshipTypeID == (Int32)InternshipScholarshipsTypesEnum.External)
            {
                ExternalInternshipScholarshipsBLL InternshipScholarship = new ExternalInternshipScholarshipsBLL();
                InternshipScholarship.InternshipScholarshipType = new InternshipScholarshipsTypesBLL()
                {
                    InternshipScholarshipTypeID = (int)InternshipScholarshipsTypesEnum.External
                };
                InternshipScholarship.InternshipScholarshipStartDate = InternshipScholarshipVM.InternshipScholarshipStartDate;
                InternshipScholarship.InternshipScholarshipEndDate   = InternshipScholarshipVM.InternshipScholarshipEndDate;
                InternshipScholarship.InternshipScholarshipReason    = InternshipScholarshipVM.InternshipScholarshipReason;
                InternshipScholarship.InternshipScholarshipLocation  = InternshipScholarshipVM.InternshipScholarshipLocation;
                InternshipScholarship.LoginIdentity = UserIdentity;
                InternshipScholarship.Country       = new CountriesBLL()
                {
                    CountryID = InternshipScholarshipVM.Country.CountryID
                };
                InternshipScholarship.InternshipScholarshipsDetails = GetInternshipScholarshipDetailsFromSession();
                Result result = InternshipScholarship.Add();

                BaseInternshipScholarshipsBLL InternshipScholarshipEntity = (BaseInternshipScholarshipsBLL)result.Entity;
                if (result.EnumMember == InternshipScholarshipsValidationEnum.Done.ToString())
                {
                    InternshipScholarshipVM.InternshipScholarshipID = ((ExternalInternshipScholarshipsBLL)result.Entity).InternshipScholarshipID;
                    //Session["InternshipScholarshipID"] = ((ExternalInternshipScholarshipsBLL)result.Entity).InternshipScholarshipID;
                    ClearInternshipScholarshipDetailsFromSession();
                }
                else if (result.EnumMember == InternshipScholarshipsValidationEnum.RejectedBecauseEmployeeRequired.ToString())
                {
                    throw new CustomException(Resources.Globalization.ValidationEmployeeRequiredText);
                }
                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 View(InternshipScholarshipVM);
            return(Json(new { InternshipScholarshipID = InternshipScholarshipVM.InternshipScholarshipID }, JsonRequestBehavior.AllowGet));
        }