/// <summary> /// Task 318: Service to Cancel EServicesProxies By System /// </summary> /// <param name="EmployeeCodeID"></param> /// <param name="Status"></param> /// <param name="CancellationReason"></param> /// <returns></returns> public Result RevokeEServiceProxyByEmployeeCodeID(int EmployeeCodeID, EServicesProxiesStatusEnum Status, string CancellationReason) { try { Result result = new Result(); foreach (EServicesProxies item in new EServicesProxiesDAL().GetActiveByFromEmployeeCodeID(EmployeeCodeID)) { result = this.RevokeEServiceProxy(item.EServiceProxyID, EServicesProxiesStatusEnum.CancelledBySystem, CancellationReason); } result.Entity = this; result.EnumType = typeof(EServicesProxiesEnum); result.EnumMember = EServicesProxiesEnum.Done.ToString(); return(result); } catch (Exception ex) { throw ex; } }
public Result RevokeEServiceProxy(int EServiceProxyID, EServicesProxiesStatusEnum Status, string CancellationReason = "") { try { Result result = new Result(); EServicesProxies EServiceProxy = new EServicesProxiesDAL().GetActiveByEServiceProxyID(EServiceProxyID); if (EServiceProxy == null || EServiceProxy.EServiceProxyID <= 0) { result = new Result(); result.Entity = null; result.EnumType = typeof(EServicesAuthorizationsEnum); result.EnumMember = EServicesProxiesEnum.RejectedBecauseEServiceProxyIsNotActive.ToString(); return(result); } int ToEmployeeCodeID = EServiceProxy.ToEmployeeCodeID; int FromEmployeeCodeID = EServiceProxy.FromEmployeeCodeID; EServiceProxy = new EServicesProxies() { EServiceProxyID = EServiceProxyID, EndDate = DateTime.Now, EServiceProxyStatusID = (int)Status, IsActive = false, CancellationReason = CancellationReason, LastUpdatedDate = DateTime.Now, LastUpdatedBy = this.LoginIdentity.EmployeeCodeID }; this.EServiceProxyID = new EServicesProxiesDAL().Revoke(EServiceProxy); #region Send SMS on revoke to "ToEmployee" EmployeesCodesBLL FromEmployeeCodeBLL = new EmployeesCodesBLL().GetByEmployeeCodeID(FromEmployeeCodeID); EmployeesCodesBLL ToEmployeeCodeBLL = new EmployeesCodesBLL().GetByEmployeeCodeID(ToEmployeeCodeID); SMSBLL SMSObj = new SMSBLL(); SMSObj.SendSMS(new SMSLogsBLL() { BusinssSubCategory = BusinessSubCategoriesEnum.EServicesProxies, DetailID = this.EServiceProxyID, MobileNo = ToEmployeeCodeBLL.Employee.EmployeeMobileNo, Message = string.Format(Globalization.SMSEServicesProxiesRevokeText, ToEmployeeCodeBLL.Employee.EmployeeNameAr, FromEmployeeCodeBLL.Employee.EmployeeNameAr), CreatedBy = this.LoginIdentity, }); #endregion #region Send SMS on revoke to "FromEmployee" in case of Proxy cancelled by System if (Status == EServicesProxiesStatusEnum.CancelledBySystem) { SMSObj.SendSMS(new SMSLogsBLL() { BusinssSubCategory = BusinessSubCategoriesEnum.EServicesProxies, DetailID = this.EServiceProxyID, MobileNo = FromEmployeeCodeBLL.Employee.EmployeeMobileNo, Message = string.Format(Globalization.SMSEServicesProxiesRevokeBySytemText, FromEmployeeCodeBLL.Employee.EmployeeNameAr, CancellationReason), CreatedBy = this.LoginIdentity, }); } #endregion result.Entity = this; result.EnumType = typeof(EServicesProxiesEnum); result.EnumMember = EServicesProxiesEnum.Done.ToString(); return(result); } catch (Exception ex) { throw ex; } }