private PromotionsRecordsViewModel GetByPromotionRecordID(int id) { PromotionsRecordsBLL PromotionRecordBLL = new PromotionsRecordsBLL().GetByPromotionRecordID(id); PromotionsRecordsViewModel PromotionRecordVM = new PromotionsRecordsViewModel(); if (PromotionRecordBLL != null) { PromotionRecordVM.PromotionRecordID = PromotionRecordBLL.PromotionRecordID; PromotionRecordVM.PromotionRecordDate = PromotionRecordBLL.PromotionRecordDate.Date; PromotionRecordVM.PromotionRecordNo = PromotionRecordBLL.PromotionRecordNo; PromotionRecordVM.JobCategoryID = PromotionRecordBLL.JobCategory.JobCategoryID; PromotionRecordVM.RankID = PromotionRecordBLL.Rank.RankID; PromotionRecordVM.RankName = PromotionRecordBLL.Rank.RankName; PromotionRecordVM.YearID = PromotionRecordBLL.PromotionPeriod.Year.MaturityYearID; PromotionRecordVM.PromotionPeriodID = PromotionRecordBLL.PromotionPeriod.PromotionPeriodID; PromotionRecordVM.PromotionPeriod = PromotionRecordBLL.PromotionPeriod; PromotionRecordVM.PromotionRecordStatus = new PromotionsRecordsStatusViewModel() { PromotionRecordStatusID = PromotionRecordBLL.PromotionRecordStatus.PromotionRecordStatusID, PromotionRecordStatusName = PromotionRecordBLL.PromotionRecordStatus.PromotionRecordStatusName }; PromotionRecordVM.PromotionRecordToolbarID = GetPromotionRecordToolbarID(PromotionRecordBLL.PromotionRecordStatus.PromotionRecordStatusID); //PromotionRecordVM.CreatedDate = PromotionRecordBLL.CreatedDate; //PromotionRecordVM.CreatedBy = PromotionRecordVM.GetCreatedByDisplayed(PromotionRecordBLL.CreatedBy); } return(PromotionRecordVM); }
public JsonResult Close(int PromotionRecordID) { PromotionsRecordsBLL PromotionsRecordsBLL = new PromotionsRecordsBLL() { LoginIdentity = UserIdentity }; Result result = PromotionsRecordsBLL.Close(PromotionRecordID); if (result.EnumMember == PromotionsRecordsValidationEnum.Done.ToString()) { PromotionsRecordsBLL PromotionRecordResult = (PromotionsRecordsBLL)result.Entity; var data = new { PromotionRecordToolbarID = GetPromotionRecordToolbarID(6), PromotionRecordStatus = PromotionRecordResult.PromotionRecordStatus }; return(Json(new { result = data }, JsonRequestBehavior.AllowGet)); } else if (result.EnumMember == PromotionsRecordsValidationEnum.RejectedBecausePromotionRecordStatusMustBeInstalled.ToString()) { throw new CustomException(Resources.Globalization.ValidationPromotionRecordStatusMustBeInstalledText); } else { return(Json(HttpStatusCode.ExpectationFailed, JsonRequestBehavior.AllowGet)); } }
public JsonResult GetPromotionCandidates(int RankID, int JobCategoryID, int PromotionPeriodID) { Session["PromotionRecordEmployees"] = null; if (RankID == 0 || JobCategoryID == 0 || PromotionPeriodID == 0) { throw new CustomException(@Resources.Globalization.RankAndPromotionPeriodAndJobCategoryShouldBeSelectedText.ToString()); } Result result = new Result(); result = new PromotionsRecordsBLL() { LoginIdentity = this.UserIdentity }.GetCandidatesShouldBeInPromotionRecord(JobCategoryID, PromotionPeriodID, RankID); PromotionsRecordsBLL PromotionRecord = (PromotionsRecordsBLL)result.Entity; //List<PromotionsRecordsEmployeesBLL> PromotionsRecordsEmployeesBLLList = PromotionRecord.PromotionsRecordsEmployees; if (result.EnumMember == PromotionsRecordsValidationEnum.RejectedBecauseThereArePormotionRecordsNotInstalled.ToString()) { Session["PromotionRecordEmployees"] = null; throw new CustomException(string.Format(@Resources.Globalization.ValidationPormotionRecordsNotInstalledText.ToString(), PromotionRecord.PromotionRecordNo, PromotionRecord.JobCategory.JobCategoryName)); } else if (PromotionRecord.PromotionsRecordsEmployees == null || PromotionRecord.PromotionsRecordsEmployees.Count == 0) { throw new CustomException(@Resources.Globalization.ValidationNoCandidatesEligibleInPromotionRecordText.ToString()); } Session["PromotionRecordEmployees"] = PromotionRecord.PromotionsRecordsEmployees; return(this.GetSpecificDataFromCandidates(PromotionRecord.PromotionsRecordsEmployees)); }
public ActionResult Create(PromotionsRecordsViewModel PromotionsRecordsVM) { Result result = new Result(); PromotionsRecordsBLL PromotionRecord = new PromotionsRecordsBLL() { PromotionRecordDate = PromotionsRecordsVM.PromotionRecordDate, PromotionPeriod = new PromotionsPeriodsBLL() { PromotionPeriodID = PromotionsRecordsVM.PromotionPeriodID }, JobCategory = new JobsCategoriesBLL() { JobCategoryID = PromotionsRecordsVM.JobCategoryID }, Rank = new RanksBLL() { RankID = PromotionsRecordsVM.RankID }, PromotionsRecordsEmployees = Session["PromotionRecordEmployees"] != null ? (List <PromotionsRecordsEmployeesBLL>)Session["PromotionRecordEmployees"] : null, LoginIdentity = this.UserIdentity }; result = PromotionRecord.Add(); PromotionsRecordsBLL PromotionRecordObj = (PromotionsRecordsBLL)result.Entity; if (result.EnumMember == PromotionsRecordsValidationEnum.Done.ToString()) { PromotionsRecordsVM.PromotionRecordID = PromotionRecordObj.PromotionRecordID; PromotionsRecordsVM.PromotionRecordNo = PromotionRecordObj.PromotionRecordNo; PromotionsRecordsVM.PromotionRecordDate = PromotionRecordObj.PromotionRecordDate; PromotionsRecordsVM.PromotionRecordStatus = new PromotionsRecordsStatusViewModel() { PromotionRecordStatusName = PromotionRecordObj.PromotionRecordStatus.PromotionRecordStatusName }; } else if (result.EnumMember == PromotionsRecordsValidationEnum.RejectedBecauseThereArePormotionRecordsNotClosedInOtherRanks.ToString()) { Session["PromotionRecordEmployees"] = null; throw new CustomException(string.Format(@Resources.Globalization.ValidationPormotionRecordsNotClosedInOtherRanksText.ToString(), PromotionRecordObj.PromotionRecordNo, PromotionRecordObj.JobCategory.JobCategoryName, PromotionRecordObj.Rank.RankName)); } else if (result.EnumMember == PromotionsRecordsValidationEnum.RejectedBecauseThereArePormotionRecordsNotInstalled.ToString()) { Session["PromotionRecordEmployees"] = null; throw new CustomException(string.Format(@Resources.Globalization.ValidationPormotionRecordsNotInstalledText.ToString(), PromotionRecordObj.PromotionRecordNo, PromotionRecordObj.JobCategory.JobCategoryName)); } else if (result.EnumMember == PromotionsRecordsValidationEnum.RejectedBecauseOfNoJobsVacanciesAvailable.ToString()) { Session["PromotionRecordEmployees"] = null; throw new CustomException(@Resources.Globalization.ValidationNoJobsVacanciesAvailableText.ToString()); } else if (result.EnumMember == PromotionsRecordsValidationEnum.RejectedBecauseOfNoCandidatesEligible.ToString()) { Session["PromotionRecordEmployees"] = null; throw new CustomException(@Resources.Globalization.ValidationNoCandidatesEligibleInPromotionRecordText.ToString()); } return(Json(PromotionsRecordsVM)); }
public ActionResult Preference(PromotionsRecordsViewModel PromotionsRecordsVM) { Result result = new Result(); PromotionsRecordsBLL pp = new PromotionsRecordsBLL() { PromotionRecordID = PromotionsRecordsVM.PromotionRecordID.Value, JobCategory = new JobsCategoriesBLL() { JobCategoryID = PromotionsRecordsVM.JobCategoryID }, Rank = new RanksBLL() { RankID = PromotionsRecordsVM.RankID }, LoginIdentity = this.UserIdentity }; result = pp.Preference(); if (result.EnumMember == PromotionsRecordsValidationEnum.Done.ToString()) { PromotionsRecordsBLL oo = (PromotionsRecordsBLL)result.Entity; PromotionsRecordsVM.PromotionRecordID = oo.PromotionRecordID; //PromotionsRecordsVM.PromotionRecordNo = oo.PromotionRecordNo; //PromotionsRecordsVM.PromotionRecordDate = oo.PromotionRecordDate; PromotionsRecordsVM.PromotionRecordStatus = new PromotionsRecordsStatusViewModel() { PromotionRecordStatusID = oo.PromotionRecordStatus.PromotionRecordStatusID, PromotionRecordStatusName = oo.PromotionRecordStatus.PromotionRecordStatusName }; } else if (result.EnumMember == PromotionsRecordsValidationEnum.RejectedBecauseOfNoJobsVacanciesAvailable.ToString()) { throw new CustomException(@Resources.Globalization.ValidationNoJobsVacanciesAvailableText.ToString()); } else if (result.EnumMember == PromotionsRecordsValidationEnum.RejectedBecauseOfNoCandidatesEligible.ToString()) { throw new CustomException(@Resources.Globalization.ValidationNoCandidatesEligibleInPromotionRecordText.ToString()); } else if (result.EnumMember == PromotionsRecordsValidationEnum.RejectedBecauseOfSomeQualifitionPointsAreNull.ToString()) { throw new CustomException(@Resources.Globalization.ValidationSomeQualifitionPointsAreNullInPromotionRecordText.ToString()); } else if (result.EnumMember == PromotionsRecordsValidationEnum.RejectedBecausePromotionRecordStatusMustBeOpen.ToString()) { throw new CustomException(@Resources.Globalization.ValidationPromotionRecordStatusMustBeOpenText.ToString()); } //PromotionRecordVM.PromotionRecordToolbarID = GetPromotionRecordToolbarID(PromotionRecordBLL.PromotionRecordStatus.PromotionRecordStatusID); return(Json(new { PromotionRecordStatus = PromotionsRecordsVM.PromotionRecordStatus, PromotionRecordToolbarID = GetPromotionRecordToolbarID(PromotionsRecordsVM.PromotionRecordStatus.PromotionRecordStatusID) }, JsonRequestBehavior.AllowGet)); }
public JsonResult RefreshPromotionRecord(int PromotionRecordID) { Result result = new PromotionsRecordsBLL() { LoginIdentity = this.UserIdentity }.RefreshPromotionRecord(PromotionRecordID); PromotionsRecordsBLL PromotionRecord = (PromotionsRecordsBLL)result.Entity; if (result.EnumMember == PromotionsRecordsValidationEnum.RejectedBecauseThereArePormotionRecordsNotInstalled.ToString()) { throw new CustomException(string.Format(@Resources.Globalization.ValidationPormotionRecordsNotInstalledText.ToString(), PromotionRecord.PromotionRecordNo, PromotionRecord.JobCategory.JobCategoryName)); } return(this.GetSpecificDataFromCandidates(PromotionRecord.PromotionsRecordsEmployees)); }
public JsonResult SetPromotionDate(string PromotionRecordID, string PromotionDate) { PromotionsRecordsBLL PromotionRecord = new PromotionsRecordsBLL(); PromotionRecord.PromotionRecordID = int.Parse(PromotionRecordID); PromotionRecord.PromotionDate = Convert.ToDateTime(Globals.Calendar.UmAlquraToGreg(PromotionDate), new CultureInfo("en-US")); PromotionRecord.LoginIdentity = UserIdentity; Result result = PromotionRecord.UpdatePromotionDate(); if (result.EnumMember == PromotionsRecordsValidationEnum.RejectedBecausePromotionDateShouldBeLessThanPromotionRecordDate.ToString()) { throw new CustomException(Resources.Globalization.ValidationPromotionDateShouldBeLessThanPromotionRecordDateText); } return(Json(HttpStatusCode.OK, JsonRequestBehavior.AllowGet)); }
public JsonResult Delete(int id) { Result result = new Result(); result = new PromotionsRecordsBLL() { LoginIdentity = this.UserIdentity }.Remove(id); if (result.EnumMember == PromotionsRecordsValidationEnum.RejectedBecauseOfNoPromotionRecordSelectedToDelete.ToString()) { throw new CustomException(@Resources.Globalization.ValidationNoPromotionRecordSelectedToDeleteText.ToString()); } Session["PromotionRecordEmployees"] = null; return(Json(new { data = id }, JsonRequestBehavior.AllowGet)); //return new HttpResponseMessage(HttpStatusCode.OK); }
public JsonResult GetPromotionsRecords() { Session["PromotionRecordEmployees"] = null; var list = new PromotionsRecordsBLL().GetPromotionsRecords() .Select(x => new { PromotionRecordID = x.PromotionRecordID, PromotionRecordNo = x.PromotionRecordNo, PromotionRecordDate = x.PromotionRecordDate, RankName = x.Rank.RankName, JobCategoryName = x.JobCategory.JobCategoryName, PromotionYear = x.PromotionPeriod.Year.MaturityYear, PromotionPeriod = x.PromotionPeriod.Period.PeriodName, PromotionRecordStatusName = x.PromotionRecordStatus.PromotionRecordStatusName, TotalJobVacancies = x.TotalJobVacancies, TotalIncludedCandidates = x.TotalIncludedCandidates, TotalPromotedCandidates = x.TotalPromotedCandidates, CreatedBy = x.CreatedBy != null ? x.CreatedBy.Employee.EmployeeNameAr : string.Empty, CreatedDate = x.CreatedDate }); return(Json(new { data = list }, JsonRequestBehavior.AllowGet)); }
public virtual Result Update() { try { Result result = null; #region Validation for dates if (this.PromotionStartDate > this.PromotionEndDate) { result = new Result(); result.Entity = null; result.EnumType = typeof(PromotionsPeriodsValidationEnum); result.EnumMember = PromotionsPeriodsValidationEnum.RejectedBecauseOfPromotionStartDateIsGreaterThenPromotionEndDate.ToString(); return(result); } #endregion #region Check if there is any promotion record exist List <PromotionsRecordsBLL> PromotionsRecords = new PromotionsRecordsBLL().GetPromotionsRecords().Where(x => x.PromotionPeriod.PromotionPeriodID.Equals(this.PromotionPeriodID)).ToList(); if (PromotionsRecords.Count > 0) { result = IsNoConflictWithPromotionStartAndPromotionEndDates(this.PromotionStartDate, this.PromotionEndDate); if (result != null) { return(result); } } #endregion #region Check if there is any active promotion period if (this.IsActive == true) { List <PromotionsPeriodsBLL> ActivePromotionsPeriods = GetPromotionsPeriods().Where(x => x.IsActive == true && x.PromotionPeriodID != this.PromotionPeriodID).ToList(); if (ActivePromotionsPeriods.Count > 0) { result = new Result(); result.Entity = null; result.EnumType = typeof(PromotionsPeriodsValidationEnum); result.EnumMember = PromotionsPeriodsValidationEnum.RejectedBecauseOfAlreadyOnePromotionPeriodIsActive.ToString(); return(result); } } #endregion PromotionsPeriods PromotionPeriod = new PromotionsPeriods(); PromotionPeriod.PromotionPeriodID = this.PromotionPeriodID; PromotionPeriod.PeriodID = this.Period.PeriodID; PromotionPeriod.YearID = this.Year.MaturityYearID; PromotionPeriod.PromotionStartDate = this.PromotionStartDate; PromotionPeriod.PromotionEndDate = this.PromotionEndDate; PromotionPeriod.IsActive = this.IsActive; PromotionPeriod.LastUpdatedDate = DateTime.Now; PromotionPeriod.LastUpdatedBy = this.LoginIdentity.EmployeeCodeID; int UpdateResult = new PromotionsPeriodsDAL().Update(PromotionPeriod); if (UpdateResult != 0) { result = new Result(); result.Entity = this; result.EnumType = typeof(PromotionsPeriodsValidationEnum); result.EnumMember = PromotionsPeriodsValidationEnum.Done.ToString(); } return(result); } catch { throw; } }
public JsonResult GetPromotionDate(int PromotionRecordID) { PromotionsRecordsBLL PromotionsRecord = new PromotionsRecordsBLL().GetByPromotionRecordID(PromotionRecordID); return(Json(PromotionsRecord.PromotionDate.ToString(System.Configuration.ConfigurationManager.AppSettings["DateFormat"]), JsonRequestBehavior.AllowGet)); }
public ActionResult UndoInstall(PromotionsRecordsViewModel PromotionsRecordsVM) { Result result = new Result(); PromotionsRecordsBLL pp = new PromotionsRecordsBLL() { PromotionRecordID = PromotionsRecordsVM.PromotionRecordID.Value, JobCategory = new JobsCategoriesBLL() { JobCategoryID = PromotionsRecordsVM.JobCategoryID }, Rank = new RanksBLL() { RankID = PromotionsRecordsVM.RankID }, LoginIdentity = this.UserIdentity }; result = pp.UndoInstall(); if (result.EnumMember == PromotionsRecordsValidationEnum.Done.ToString()) { PromotionsRecordsBLL oo = (PromotionsRecordsBLL)result.Entity; PromotionsRecordsVM.PromotionRecordID = oo.PromotionRecordID; //PromotionsRecordsVM.PromotionRecordNo = oo.PromotionRecordNo; //PromotionsRecordsVM.PromotionRecordDate = oo.PromotionRecordDate; PromotionsRecordsVM.PromotionRecordStatus = new PromotionsRecordsStatusViewModel() { PromotionRecordStatusID = oo.PromotionRecordStatus.PromotionRecordStatusID, PromotionRecordStatusName = oo.PromotionRecordStatus.PromotionRecordStatusName }; } else if (result.EnumMember == PromotionsRecordsValidationEnum.RejectedBecauseOfNoJobsVacanciesAvailable.ToString()) { throw new CustomException(@Resources.Globalization.ValidationNoJobsVacanciesAvailableText.ToString()); } else if (result.EnumMember == PromotionsRecordsValidationEnum.RejectedBecauseOfNoCandidatesEligible.ToString()) { throw new CustomException(@Resources.Globalization.ValidationNoCandidatesEligibleInPromotionRecordText.ToString()); } else if (result.EnumMember == PromotionsRecordsValidationEnum.RejectedBecausePromotionRecordStatusMustBeInstalled.ToString()) { throw new CustomException(@Resources.Globalization.ValidationPromotionRecordStatusMustBeInstalledText.ToString()); } else if (result.EnumMember == PromotionsRecordsValidationEnum.RejectedBecauseOfAssignedJobCategoryIsInInstalledStatus.ToString()) { PromotionsRecordsBLL ooo = (PromotionsRecordsBLL)result.Entity; //PromotionsRecordsVM.PromotionRecordID = ooo.PromotionRecordID; //PromotionsRecordsVM.PromotionRecordStatus = new PromotionsRecordsStatusViewModel() //{ // PromotionRecordStatusID = ooo.PromotionRecordStatus.PromotionRecordStatusID, // PromotionRecordStatusName = ooo.PromotionRecordStatus.PromotionRecordStatusName //}; throw new CustomException(string.Format(@Resources.Globalization.ValidationPromotionRecordCannotUndoInsalledBecauseAssignedJobCategoryHasInstalledStatusText.ToString(), ooo.PromotionRecordNo, ooo.JobCategory.JobCategoryName)); //throw new CustomException(@Resources.Globalization.ValidationPromotionRecordCannotUndoInsalledBecauseAssignedJobCategoryHasInstalledStatusText.ToString()); } return(Json(new { PromotionRecordStatus = PromotionsRecordsVM.PromotionRecordStatus, PromotionRecordToolbarID = GetPromotionRecordToolbarID(PromotionsRecordsVM.PromotionRecordStatus.PromotionRecordStatusID) }, JsonRequestBehavior.AllowGet)); }