public ActionResult Edit(int id)
        {
            ScholarshipsViewModel ScholarshipVM = new ScholarshipsViewModel();
            BaseScholarshipsBLL   Scholarship   = this.GetByScholarshipID(id);

            if (Scholarship != null && Scholarship.ScholarshipID > 0)
            {
                Scholarship = Scholarship.GetByScholarshipID(id);
                //ScholarshipVM.ScholarshipTypeID = (int)Scholarship.ScholarshipType;
                ScholarshipVM.ScholarshipType = new ScholarshipsTypesBLL()
                {
                    ScholarshipTypeID = Convert.ToInt32(Scholarship.ScholarshipTypeEnum)
                };
                if ((int)Scholarship.ScholarshipTypeEnum == (Int16)ScholarshipsTypesEnum.External)
                {
                    ScholarshipVM.Country = ((ExternalScholarshipsBLL)Scholarship).Country;
                }
                if ((int)Scholarship.ScholarshipTypeEnum == (Int16)ScholarshipsTypesEnum.Internal)
                {
                    ScholarshipVM.KSACity  = ((InternalScholarshipsBLL)Scholarship).KSACity;
                    ScholarshipVM.Location = ((InternalScholarshipsBLL)Scholarship).Location;
                }
                ScholarshipVM.ScholarshipID        = Scholarship.ScholarshipID;
                ScholarshipVM.ScholarshipReason    = Scholarship.ScholarshipReason;
                ScholarshipVM.ScholarshipStartDate = Scholarship.ScholarshipStartDate;
                ScholarshipVM.ScholarshipEndDate   = Scholarship.ScholarshipEndDate;
                ScholarshipVM.ScholarshipPeriod    = Scholarship.ScholarshipPeriod;
            }

            return(View(ScholarshipVM));
        }
        public ActionResult Edit(ScholarshipsViewModel ScholarshipVM)
        {
            BaseScholarshipsBLL Scholarship = null;

            if (ScholarshipVM.ScholarshipType.ScholarshipTypeID == (int)ScholarshipsTypesEnum.Internal)
            {
                Scholarship = GenericFactoryPattern <BaseScholarshipsBLL, InternalScholarshipsBLL> .CreateInstance();

                ((InternalScholarshipsBLL)Scholarship).Location = ScholarshipVM.Location;
            }
            else if (ScholarshipVM.ScholarshipType.ScholarshipTypeID == (int)ScholarshipsTypesEnum.External)
            {
                Scholarship = GenericFactoryPattern <BaseScholarshipsBLL, ExternalScholarshipsBLL> .CreateInstance();
            }

            Scholarship.ScholarshipID        = ScholarshipVM.ScholarshipID;
            Scholarship.ScholarshipStartDate = ScholarshipVM.ScholarshipStartDate.Value.Date;
            Scholarship.ScholarshipEndDate   = ScholarshipVM.ScholarshipEndDate.Value.Date;
            Scholarship.ScholarshipReason    = ScholarshipVM.ScholarshipReason;
            Scholarship.LoginIdentity        = this.UserIdentity;
            Result result = Scholarship.Edit();

            if (result.EnumMember == ScholarshipsValidationEnum.RejectedBecauseOfAlreadyCanceled.ToString())
            {
                throw new CustomException(Resources.Globalization.ValidationScholarshipsAlreadyCanceledText);
            }
            else if (result.EnumMember == ScholarshipsValidationEnum.RejectedBecauseOfAlreadyPassed.ToString())
            {
                throw new CustomException(Resources.Globalization.ValidationScholarshipsAlreadyPassedText);
            }

            Classes.Helpers.CommonHelper.ConflictValidationMessage(result);

            return(Json(new { ScholarshipID = Scholarship.ScholarshipID }, JsonRequestBehavior.AllowGet));
        }
        public ActionResult Delete(ScholarshipsViewModel ScholarshipVM)
        {
            BaseScholarshipsBLL baseScholarshipsBLL = new HCMBLL.BaseScholarshipsBLL();

            baseScholarshipsBLL.LoginIdentity = UserIdentity;
            baseScholarshipsBLL.Remove(ScholarshipVM.ScholarshipID);
            return(RedirectToAction("Index"));
        }
        public ActionResult Create(ScholarshipsViewModel ScholarshipVM)
        {
            BaseScholarshipsBLL EmployeeScholarship = null;

            switch (ScholarshipVM.ScholarshipType.ScholarshipTypeID)
            {
            case (int)ScholarshipsTypesEnum.Internal:
            {
                EmployeeScholarship = GenericFactoryPattern <BaseScholarshipsBLL, InternalScholarshipsBLL> .CreateInstance();

                EmployeeScholarship.ScholarshipTypeEnum  = (ScholarshipsTypesEnum)ScholarshipVM.ScholarshipType.ScholarshipTypeID;
                EmployeeScholarship.ScholarshipStartDate = ScholarshipVM.ScholarshipStartDate.Value;
                EmployeeScholarship.ScholarshipEndDate   = ScholarshipVM.ScholarshipEndDate.Value;
                EmployeeScholarship.Employee             = new EmployeesCodesBLL()
                {
                    EmployeeCodeID = ScholarshipVM.EmployeeCodeID
                };
                ((InternalScholarshipsBLL)EmployeeScholarship).Location = ScholarshipVM.Location;
                ((InternalScholarshipsBLL)EmployeeScholarship).KSACity  = new KSACitiesBLL()
                {
                    KSACityID = ScholarshipVM.KSACity.KSACityID
                };
                EmployeeScholarship.ScholarshipReason = ScholarshipVM.ScholarshipReason;
                EmployeeScholarship.Qualification     = new QualificationsBLL()
                {
                    QualificationID = ScholarshipVM.Qualification.QualificationID
                };
                EmployeeScholarship.LoginIdentity = UserIdentity;
                Result result = EmployeeScholarship.Add();

                if (result.EnumMember == ScholarshipsValidationEnum.Done.ToString())
                {
                    ScholarshipVM.ScholarshipID = ((InternalScholarshipsBLL)result.Entity).ScholarshipID;
                }

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

            case (int)ScholarshipsTypesEnum.External:
            {
                EmployeeScholarship = GenericFactoryPattern <BaseScholarshipsBLL, ExternalScholarshipsBLL> .CreateInstance();

                EmployeeScholarship.ScholarshipTypeEnum  = (ScholarshipsTypesEnum)ScholarshipVM.ScholarshipType.ScholarshipTypeID;
                EmployeeScholarship.ScholarshipStartDate = ScholarshipVM.ScholarshipStartDate.Value;
                EmployeeScholarship.ScholarshipEndDate   = ScholarshipVM.ScholarshipEndDate.Value;
                EmployeeScholarship.Employee             = new EmployeesCodesBLL()
                {
                    EmployeeCodeID = ScholarshipVM.EmployeeCodeID
                };
                EmployeeScholarship.ScholarshipReason = ScholarshipVM.ScholarshipReason;
                ((ExternalScholarshipsBLL)EmployeeScholarship).Country = new CountriesBLL()
                {
                    CountryID = ScholarshipVM.Country.CountryID
                };
                EmployeeScholarship.Qualification = new QualificationsBLL()
                {
                    QualificationID = ScholarshipVM.Qualification.QualificationID
                };
                EmployeeScholarship.LoginIdentity = UserIdentity;
                Result result = EmployeeScholarship.Add();

                if (result.EnumMember == ScholarshipsValidationEnum.Done.ToString())
                {
                    ScholarshipVM.ScholarshipID = ((ExternalScholarshipsBLL)result.Entity).ScholarshipID;
                }
                Classes.Helpers.CommonHelper.ConflictValidationMessage(result);
                break;
            }

            default:
                break;
            }

            return(Json(new { ScholarshipID = ScholarshipVM.ScholarshipID }, JsonRequestBehavior.AllowGet));
        }