public ActionResult End(AssigningsViewModel AssigningVM) { BaseAssigningsBLL assigning = new BaseAssigningsBLL(); assigning.AssigningID = AssigningVM.AssigningID; assigning.LoginIdentity = UserIdentity; Result result = assigning.BreakLastAssigning(AssigningVM.EmployeeCodeID, DateTime.Now, (AssigningsReasonsEnum)AssigningVM.EndAssigningReasonID, assigning.Notes); if (result.EnumMember == OrganizationStructureValidationEnum.RejectedBecauseOfPlacementPeriodFinished.ToString()) { throw new CustomException(Resources.Globalization.EmployeesPlacementPeriodFinishedText); } return(View(AssigningVM)); }
public ActionResult Delete(AssigningsViewModel AssigningVM) { BaseAssigningsBLL assigningsBLL = new BaseAssigningsBLL(); assigningsBLL.LoginIdentity = UserIdentity; Result result = assigningsBLL.Remove(AssigningVM.AssigningID); if ((System.Type)result.EnumType == typeof(AssigningsValidationEnum)) { if (result.EnumMember == AssigningsValidationEnum.RejectedBecauseOfAlreadyFinished.ToString()) { throw new CustomException(Resources.Globalization.ValidationBecauseOfAssigningAlreadyFinishedText); } } return(View(AssigningVM)); }
public HttpResponseMessage EndingEmployeeAssigning(AssigningsViewModel AssigningVM) { BaseAssigningsBLL assigning = (InternalAssigningBLL)AssigingsFactory.CreateAssigning(AssigningsTypesEnum.Internal); assigning.AssigningID = AssigningVM.AssigningID; assigning.LoginIdentity = WindowsEmployeeCode; //assigning.EmployeeCareerHistory = new EmployeesCareersHistoryBLL() { EmployeeCode = new EmployeesCodesBLL() { emplo } } //assigning.AssigningEndDate = DateTime.Now; //assigning.AssigningEndReason = new AssigningsReasonsBLL() { AssigningReasonID = AssigningVM.EndAssigningReasonID }; //assigning.Notes = AssigningVM.Notes; Result result = assigning.BreakLastAssigning(AssigningVM.EmployeeCodeID, DateTime.Now, (AssigningsReasonsEnum)AssigningVM.EndAssigningReasonID, assigning.Notes); if (result.EnumMember == OrganizationStructureValidationEnum.RejectedBecauseOfPlacementPeriodFinished.ToString()) { throw new CustomException(Resources.Globalization.EmployeesPlacementPeriodFinishedText); } else { return(new HttpResponseMessage(HttpStatusCode.OK)); } }
private AssigningsViewModel GetByAssigningID(int id) { BaseAssigningsBLL AssigningBLL = BaseAssigningsBLL.GetByAssigningID(id); AssigningsViewModel AssigningVM = new AssigningsViewModel(); if (AssigningBLL != null) { AssigningVM.ExternalKSACity = new KSACitiesBLL() { KSACityID = 0 }; // set default to avoid Object reference error. if (AssigningBLL.AssigningType.AssigningTypeID == (Int32)AssigningsTypesEnum.Internal) { if (((InternalAssigningBLL)AssigningBLL).Job != null) { AssigningVM.Job = new JobsViewModel() { JobID = ((InternalAssigningBLL)AssigningBLL).Job.JobID, JobName = ((InternalAssigningBLL)AssigningBLL).Job.JobName }; } AssigningVM.OrganizationStructure = new OrganizationStructureViewModel() { OrganizationID = ((InternalAssigningBLL)AssigningBLL).Organization.OrganizationID, OrganizationName = ((InternalAssigningBLL)AssigningBLL).Organization.OrganizationName, FullOrganizationName = ((InternalAssigningBLL)AssigningBLL).Organization.FullOrganizationName }; if (((InternalAssigningBLL)AssigningBLL).Manager != null) { AssigningVM.Manager = new ParentOrganizationManagerViewModel() { ManagerCodeID = ((InternalAssigningBLL)AssigningBLL).Manager.EmployeeCodeID, ManagerCodeNo = ((InternalAssigningBLL)AssigningBLL).Manager.EmployeeCodeNo, ManagerNameAr = ((InternalAssigningBLL)AssigningBLL).Manager.Employee.EmployeeNameAr, }; } } else if (AssigningBLL.AssigningType.AssigningTypeID == (Int32)AssigningsTypesEnum.External) { AssigningVM.ExternalOrganization = ((ExternalAssigningBLL)AssigningBLL).ExternalOrganization; AssigningVM.ExternalKSARegion = ((ExternalAssigningBLL)AssigningBLL).ExternalKSACity.KSARegion; AssigningVM.ExternalKSACity = ((ExternalAssigningBLL)AssigningBLL).ExternalKSACity; AssigningVM.Job = new JobsViewModel(); AssigningVM.OrganizationStructure = new OrganizationStructureViewModel(); } AssigningVM.AssigningType = AssigningBLL.AssigningType; AssigningVM.AssigningID = AssigningBLL.AssigningID; AssigningVM.AssginingStartDate = AssigningBLL.AssigningStartDate; AssigningVM.AssginingEndDate = AssigningBLL.AssigningEndDate; AssigningVM.IsFinished = AssigningBLL.IsFinished; if (AssigningBLL.AssigningReason != null && AssigningBLL.AssigningReason.AssigningReasonID > 0) { AssigningVM.AssigningReason = AssigningBLL.AssigningReason; AssigningVM.AssigningReasonOther = AssigningBLL.AssigningReasonOther; } AssigningVM.EmployeeCodeID = AssigningBLL.EmployeeCareerHistory.EmployeeCode.EmployeeCodeID; AssigningVM.Employee = new EmployeesViewModel() { EmployeeCodeID = AssigningBLL.EmployeeCareerHistory.EmployeeCode.EmployeeCodeID }; AssigningVM.Employee = AssigningVM.Employee.GetEmployee(); AssigningVM.CreatedDate = AssigningBLL.CreatedDate; AssigningVM.CreatedBy = AssigningVM.GetCreatedByDisplayed(AssigningBLL.CreatedBy); } return(AssigningVM); }
public ActionResult EditAssigning(AssigningsViewModel AssigningVM) { if (AssigningVM.AssigningType.AssigningTypeID == (Int32)AssigningsTypesEnum.Internal) { InternalAssigningBLL assigning = (InternalAssigningBLL)AssigingsFactory.CreateAssigning(AssigningsTypesEnum.Internal); assigning.AssigningID = AssigningVM.AssigningID; assigning.AssigningType = new AssigningsTypesBLL() { AssigningTypeID = (Int32)AssigningsTypesEnum.Internal }; assigning.AssigningStartDate = AssigningVM.AssginingStartDate.Value.Date; //assigning.AssigningEndDate = AssigningVM.AssginingEndDate.HasValue ? AssigningVM.AssginingEndDate.Value.Date : (DateTime?)null; //assigning.IsFinished = AssigningVM.IsFinished; assigning.EmployeeCareerHistory = new EmployeesCareersHistoryBLL() { EmployeeCareerHistoryID = AssigningVM.EmployeeCareerHistoryID }; assigning.Job = new JobsBLL() { JobID = AssigningVM.JobID.HasValue ? AssigningVM.JobID.Value : 0 }; assigning.Organization = new OrganizationsStructuresBLL() { OrganizationID = AssigningVM.OrganizationID.Value }; assigning.Manager = AssigningVM.ManagerCodeID.HasValue ? new EmployeesCodesBLL() { EmployeeCodeID = AssigningVM.ManagerCodeID.Value } : null; assigning.AssigningReason = new AssigningsReasonsBLL() { AssigningReasonID = AssigningVM.AssigningReason.AssigningReasonID }; assigning.LoginIdentity = new EmployeesCodesBLL() { EmployeeCodeID = int.Parse(Session["EmployeeCodeID"].ToString()) }; assigning.AssigningReasonOther = AssigningVM.AssigningReasonOther; Result result = assigning.Update(); if ((System.Type)result.EnumType == typeof(AssigningsValidationEnum)) { if (result.EnumMember == AssigningsValidationEnum.Done.ToString()) { BaseAssigningsBLL assgining = (BaseAssigningsBLL)result.Entity; Session["AssigningID"] = ((InternalAssigningBLL)result.Entity).AssigningID; } else if (result.EnumMember == AssigningsValidationEnum.RejectedBecauseOfAlreadyFinished.ToString()) { throw new CustomException(Resources.Globalization.ValidationBecauseOfAssigningAlreadyFinishedText); } //else if (result.EnumMember == AssigningsValidationEnum.RejectedBecauseOfActivePreviousAssigning.ToString()) //{ // BaseAssigningsBLL assgining = (BaseAssigningsBLL)result.Entity; // throw new CustomException(Resources.Globalization.MustEndPreviousAssigningText + "NewLine" + "تاريخ اخر تكليف : " + assgining.AssigningStartDate.ToShortDateString()); //} else if (result.EnumMember == AssigningsValidationEnum.RejectedBecauseOfConflictWithLenders.ToString()) { LendersBLL Lender = ((LendersBLL)result.Entity); throw new CustomException(string.Format(Resources.Globalization.ValidationConflictWithLenderText, Lender.LenderStartDate.ToShortDateString(), Lender.LenderEndDate.ToShortDateString())); } else if (result.EnumMember == AssigningsValidationEnum.RejectedBecauseOfEndDateIsLessThanCreationDate.ToString()) { throw new CustomException(Resources.Globalization.ValidationBecauseOfEndDateIsLessThanCreationDateText); } } } else if (AssigningVM.AssigningType.AssigningTypeID == (Int32)AssigningsTypesEnum.External) { ExternalAssigningBLL assigning = (ExternalAssigningBLL)AssigingsFactory.CreateAssigning(AssigningsTypesEnum.External); assigning.AssigningID = AssigningVM.AssigningID; assigning.AssigningType = new AssigningsTypesBLL() { AssigningTypeID = (Int32)AssigningsTypesEnum.External }; assigning.AssigningStartDate = AssigningVM.AssginingStartDate.Value.Date; //assigning.AssigningEndDate = AssigningVM.AssginingEndDate.HasValue ? AssigningVM.AssginingEndDate.Value.Date : (DateTime?)null; //assigning.IsFinished = AssigningVM.IsFinished; //assigning.Employee = new EmployeesCodesBLL() { EmployeeCodeID = AssigningVM.EmployeeCodeID }; assigning.EmployeeCareerHistory = new EmployeesCareersHistoryBLL() { EmployeeCareerHistoryID = AssigningVM.EmployeeCareerHistoryID }; assigning.ExternalKSACity = new KSACitiesBLL() { KSACityID = AssigningVM.ExternalKSACity.KSACityID }; assigning.ExternalOrganization = AssigningVM.ExternalOrganization; assigning.AssigningReason = new AssigningsReasonsBLL() { AssigningReasonID = AssigningVM.AssigningReason.AssigningReasonID }; assigning.LoginIdentity = new EmployeesCodesBLL() { EmployeeCodeID = int.Parse(Session["EmployeeCodeID"].ToString()) }; assigning.AssigningReasonOther = AssigningVM.AssigningReasonOther; Result result = assigning.Update(); if ((System.Type)result.EnumType == typeof(AssigningsValidationEnum)) { if (result.EnumMember == AssigningsValidationEnum.Done.ToString()) { BaseAssigningsBLL assgining = (BaseAssigningsBLL)result.Entity; Session["AssigningID"] = ((ExternalAssigningBLL)result.Entity).AssigningID; } else if (result.EnumMember == AssigningsValidationEnum.RejectedBecauseOfActivePreviousAssigning.ToString()) { BaseAssigningsBLL assgining = (BaseAssigningsBLL)result.Entity; throw new CustomException(Resources.Globalization.MustEndPreviousAssigningText + "NewLine" + Resources.Globalization.LastAssigningStartDateText + assgining.AssigningStartDate.ToShortDateString()); } else if (result.EnumMember == AssigningsValidationEnum.RejectedBecauseOfConflictWithLenders.ToString()) { LendersBLL Lender = ((LendersBLL)result.Entity); throw new CustomException(string.Format(Resources.Globalization.ValidationConflictWithLenderText, Lender.LenderStartDate.ToShortDateString(), Lender.LenderEndDate.ToShortDateString())); } else if (result.EnumMember == AssigningsValidationEnum.RejectedBecauseOfEndDateIsLessThanCreationDate.ToString()) { throw new CustomException(Resources.Globalization.ValidationBecauseOfEndDateIsLessThanCreationDateText); } } } return(View(this.GetByAssigningID(AssigningVM.AssigningID))); }
public ActionResult Create(AssigningsViewModel AssigningVM) { if (AssigningVM.AssigningType.AssigningTypeID == (Int32)AssigningsTypesEnum.Internal) { InternalAssigningBLL assigning = (InternalAssigningBLL)AssigingsFactory.CreateAssigning(AssigningsTypesEnum.Internal); assigning.AssigningType = new AssigningsTypesBLL() { AssigningTypeID = (int)AssigningsTypesEnum.Internal }; assigning.AssigningStartDate = AssigningVM.AssginingStartDate.Value.Date; assigning.AssigningEndDate = AssigningVM.AssginingEndDate.HasValue ? AssigningVM.AssginingEndDate.Value.Date : (DateTime?)null; assigning.EmployeeCareerHistory = new EmployeesCareersHistoryBLL().GetActiveByEmployeeCareerHistoryID(AssigningVM.EmployeeCareerHistoryID); assigning.Manager = AssigningVM.ManagerCodeID.HasValue ? new EmployeesCodesBLL() { EmployeeCodeID = AssigningVM.ManagerCodeID.Value } : null; assigning.Job = new JobsBLL() { JobID = AssigningVM.JobID.HasValue ? AssigningVM.JobID.Value : 0 }; if (AssigningVM.OrganizationID.HasValue) { assigning.Organization = new OrganizationsStructuresBLL() { OrganizationID = AssigningVM.OrganizationID.Value } } ; assigning.AssigningReason = new AssigningsReasonsBLL() { AssigningReasonID = AssigningVM.AssigningReason.AssigningReasonID }; assigning.AssigningReasonOther = AssigningVM.AssigningReasonOther; assigning.LoginIdentity = this.UserIdentity; Result result = assigning.Add(); if ((System.Type)result.EnumType == typeof(NoConflictWithOtherProcessValidationEnum)) { Classes.Helpers.CommonHelper.ConflictValidationMessage(result); } if ((System.Type)result.EnumType == typeof(AssigningsValidationEnum)) { if (result.EnumMember == AssigningsValidationEnum.Done.ToString()) { BaseAssigningsBLL assgining = (BaseAssigningsBLL)result.Entity; Session["AssigningID"] = ((InternalAssigningBLL)result.Entity).AssigningID; } else if (result.EnumMember == AssigningsValidationEnum.RejectedBecauseOfActivePreviousAssigning.ToString()) { BaseAssigningsBLL assgining = (BaseAssigningsBLL)result.Entity; throw new CustomException(Resources.Globalization.MustEndPreviousAssigningText + "NewLine" + "تاريخ اخر تكليف : " + assgining.AssigningStartDate.ToShortDateString()); } else if (result.EnumMember == AssigningsValidationEnum.RejectedBecauseOfConflictWithLenders.ToString()) { LendersBLL Lender = ((LendersBLL)result.Entity); throw new CustomException(string.Format(Resources.Globalization.ValidationConflictWithLenderText, Lender.LenderStartDate.ToShortDateString(), Lender.LenderEndDate.ToShortDateString())); } else if (result.EnumMember == AssigningsValidationEnum.RejectedBecauseOfEndDateIsLessThanCreationDate.ToString()) { throw new CustomException(Resources.Globalization.ValidationBecauseOfEndDateIsLessThanCreationDateText); } } } else if (AssigningVM.AssigningType.AssigningTypeID == (Int32)AssigningsTypesEnum.External) { ExternalAssigningBLL assigning = (ExternalAssigningBLL)AssigingsFactory.CreateAssigning(AssigningsTypesEnum.External); assigning.AssigningType = new AssigningsTypesBLL() { AssigningTypeID = (int)AssigningsTypesEnum.External }; assigning.AssigningStartDate = AssigningVM.AssginingStartDate.Value.Date; assigning.AssigningEndDate = AssigningVM.AssginingEndDate.HasValue ? AssigningVM.AssginingEndDate.Value.Date : (DateTime?)null; assigning.EmployeeCareerHistory = new EmployeesCareersHistoryBLL().GetActiveByEmployeeCareerHistoryID(AssigningVM.EmployeeCareerHistoryID); assigning.ExternalKSACity = new KSACitiesBLL() { KSACityID = AssigningVM.ExternalKSACity.KSACityID }; assigning.ExternalOrganization = AssigningVM.ExternalOrganization; assigning.AssigningReason = new AssigningsReasonsBLL() { AssigningReasonID = AssigningVM.AssigningReason.AssigningReasonID }; assigning.AssigningReasonOther = AssigningVM.AssigningReasonOther; assigning.LoginIdentity = this.UserIdentity; Result result = assigning.Add(); if ((System.Type)result.EnumType == typeof(NoConflictWithOtherProcessValidationEnum)) { Classes.Helpers.CommonHelper.ConflictValidationMessage(result); } if ((System.Type)result.EnumType == typeof(AssigningsValidationEnum)) { if (result.EnumMember == AssigningsValidationEnum.Done.ToString()) { BaseAssigningsBLL assgining = (BaseAssigningsBLL)result.Entity; Session["AssigningID"] = ((ExternalAssigningBLL)result.Entity).AssigningID; } else if (result.EnumMember == AssigningsValidationEnum.RejectedBecauseOfActivePreviousAssigning.ToString()) { BaseAssigningsBLL assgining = (BaseAssigningsBLL)result.Entity; throw new CustomException(Resources.Globalization.MustEndPreviousAssigningText + "NewLine" + "تاريخ اخر تكليف : " + assgining.AssigningStartDate.ToShortDateString()); } else if (result.EnumMember == AssigningsValidationEnum.RejectedBecauseOfConflictWithLenders.ToString()) { LendersBLL Lender = ((LendersBLL)result.Entity); throw new CustomException(string.Format(Resources.Globalization.ValidationConflictWithLenderText, Lender.LenderStartDate.ToShortDateString(), Lender.LenderEndDate.ToShortDateString())); } else if (result.EnumMember == AssigningsValidationEnum.RejectedBecauseOfEndDateIsLessThanCreationDate.ToString()) { throw new CustomException(Resources.Globalization.ValidationBecauseOfEndDateIsLessThanCreationDateText); } } } return(View(AssigningVM)); }