示例#1
0
 internal EServicesProxiesBLL MapEServiceProxy(EServicesProxies item)
 {
     return(item != null ?
            new EServicesProxiesBLL()
     {
         EServiceProxyID = item.EServiceProxyID,
         FromEmployee = new EmployeesCodesBLL().MapEmployeeCode(item.FromEmployeeCode),
         ToEmployee = new EmployeesCodesBLL().MapEmployeeCode(item.ToEmployeeCode),
         EServiceType = new EServicesTypesBLL().MapEServicesTypes(item.EServicesTypes),
         StartDate = item.StartDate,
         EndDate = item.EndDate,
         IsActive = item.IsActive,
         EServiceProxyStatus = new EServicesProxiesStatusBLL().MapEServicesProxiesStatus(item.EServicesProxiesStatus),
         Notes = item.Notes
     }
         : null);
 }
示例#2
0
        public virtual Result Add()
        {
            try
            {
                Result result = new Result();

                if (this.StartDate.ToString().Contains("0001"))
                {
                    result            = new Result();
                    result.Entity     = null;
                    result.EnumType   = typeof(EServicesProxiesEnum);
                    result.EnumMember = EServicesProxiesEnum.RejectedBecauseStartDateRequried.ToString();

                    return(result);
                }
                else if (this.LoginIdentity.EmployeeCodeID == this.ToEmployee.EmployeeCodeID)
                {
                    result            = new Result();
                    result.Entity     = null;
                    result.EnumType   = typeof(EServicesProxiesEnum);
                    result.EnumMember = EServicesProxiesEnum.RejectedBecauseLoginManagerIsSameAsProxyEmployee.ToString();

                    return(result);
                }
                else
                {
                    EServicesProxiesBLL bll = this.GetActiveByFromEmployeeCodeID(this.FromEmployee.EmployeeCodeID, (EServicesTypesEnum)this.EServiceType.EServiceTypeID);
                    if (bll != null && bll.EServiceProxyID > 0)
                    {
                        result            = new Result();
                        result.Entity     = bll;
                        result.EnumType   = typeof(EServicesProxiesEnum);
                        result.EnumMember = EServicesProxiesEnum.RejectedBecauseThereIsAlreadyActiveProxyExist.ToString();

                        return(result);
                    }

                    // Validate if ToEmployee has already EVacation Request Pending Exist
                    EmployeesCodes ToEmployee = new EmployeesCodesDAL().GetByEmployeeCodeID(this.ToEmployee.EmployeeCodeID);
                    result = new EVacationsRequestsBLL().IsEVacationRequestPendingExist(ToEmployee.EmployeeCodeNo);
                    if (result != null)
                    {
                        result            = new Result();
                        result.Entity     = null;
                        result.EnumType   = typeof(EServicesProxiesEnum);
                        result.EnumMember = EServicesProxiesEnum.RejectedBecauseThereIsPendingEVacationRequestExist.ToString();

                        return(result);
                    }

                    // Validate if ToEmployee has already Vacation Exist
                    List <BaseVacationsBLL> lst = new BaseVacationsBLL().GetByEmployeeCodeID(this.ToEmployee.EmployeeCodeID, this.StartDate, this.StartDate.AddDays(this.DaysCountInGregYear));
                    if (lst.Count > 0)
                    {
                        result            = new Result();
                        result.Entity     = null;
                        result.EnumType   = typeof(EServicesProxiesEnum);
                        result.EnumMember = EServicesProxiesEnum.RejectedBecauseThereIsVacationExist.ToString();

                        return(result);
                    }
                }

                EServicesProxies EServiceProxy = new EServicesProxies()
                {
                    EServiceTypeID        = this.EServiceType.EServiceTypeID,
                    FromEmployeeCodeID    = this.FromEmployee.EmployeeCodeID,
                    ToEmployeeCodeID      = this.ToEmployee.EmployeeCodeID,
                    StartDate             = this.StartDate,
                    EndDate               = this.EndDate,
                    EServiceProxyStatusID = (int)EServicesProxiesStatusEnum.Valid,
                    IsActive              = true,
                    Notes       = this.Notes,
                    CreatedDate = DateTime.Now,
                    CreatedBy   = this.LoginIdentity.EmployeeCodeID
                };

                this.EServiceProxyID = new EServicesProxiesDAL().Insert(EServiceProxy);

                #region Send SMS on creation
                EmployeesCodesBLL FromEmployeeCodeBLL = new EmployeesCodesBLL().GetByEmployeeCodeID(this.FromEmployee.EmployeeCodeID);
                EmployeesCodesBLL ToEmployeeCodeBLL   = new EmployeesCodesBLL().GetByEmployeeCodeID(this.ToEmployee.EmployeeCodeID);
                SMSBLL            SMSObj = new SMSBLL();
                SMSObj.SendSMS(new SMSLogsBLL()
                {
                    BusinssSubCategory = BusinessSubCategoriesEnum.EServicesProxies,
                    DetailID           = this.EServiceProxyID,
                    MobileNo           = ToEmployeeCodeBLL.Employee.EmployeeMobileNo,
                    Message            = string.Format(Globalization.SMSEServicesProxiesCreationText,
                                                       ToEmployeeCodeBLL.Employee.EmployeeNameAr, FromEmployeeCodeBLL.Employee.EmployeeNameAr),
                    CreatedBy = this.LoginIdentity,
                });
                #endregion

                result            = new Result();
                result.Entity     = this;
                result.EnumType   = typeof(EServicesProxiesEnum);
                result.EnumMember = EServicesProxiesEnum.Done.ToString();
                return(result);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
示例#3
0
        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;
            }
        }