Beispiel #1
0
        public VacationsDetailsBLL GetVacationsDetailsByVacationDetailID(int VacationDetailID)
        {
            VacationsDetailsBLL VacationDetailBLL = new VacationsDetailsBLL();
            VacationsDetails    VacationDetail    = new VacationsDetailsDAL().GetByVacationDetailID(VacationDetailID);

            return(new VacationsDetailsBLL().MapVacationDetail(VacationDetail));
        }
Beispiel #2
0
 internal VacationsDetailsBLL MapVacationDetail(VacationsDetails VacationDetail)
 {
     try
     {
         VacationsDetailsBLL VacationDetailBLL = null;
         if (VacationDetail != null)
         {
             VacationDetailBLL = new VacationsDetailsBLL()
             {
                 Vacation         = VacationDetail.Vacations != null ? new BaseVacationsBLL().MapVacation(VacationDetail.Vacations) : null,
                 VacationDetailID = VacationDetail.VacationDetailID,
                 FromDate         = VacationDetail.FromDate,
                 ToDate           = VacationDetail.ToDate,
                 IsApproved       = VacationDetail.IsApproved,
                 ApprovedDate     = VacationDetail.ApprovedDate,
                 ApprovedBy       = VacationDetail.ApprovedByNav != null ? new EmployeesCodesBLL().MapEmployeeCode(VacationDetail.ApprovedByNav) : new EmployeesCodesBLL()
                 {
                     Employee = new EmployeesBLL()
                 },
                 VacationAction = new VacationsActionsBLL()
                 {
                     VacationActionID   = VacationDetail.VacationActionID,
                     VacationActionName = VacationDetail.VacationsActions.VacationActionName
                 },
                 Notes           = VacationDetail.Notes,
                 MainframeNo     = VacationDetail.MainframeNo,
                 CreatedDate     = VacationDetail.CreatedDate,
                 CreatedBy       = new EmployeesCodesBLL().MapEmployeeCode(VacationDetail.CreatedByNav),
                 LastUpdatedDate = VacationDetail.LastUpdatedDate,
                 LastUpdatedBy   = new EmployeesCodesBLL().MapEmployeeCode(VacationDetail.LastUpdatedByNav),
             };
         }
         return(VacationDetailBLL);
     }
     catch
     {
         throw;
     }
 }
Beispiel #3
0
        public Result Remove(int VacationDetailID)
        {
            Result result = null;
            VacationsDetailsBLL VacationDetail = this.GetVacationsDetailsByVacationDetailID(VacationDetailID);

            #region validate if this action approved or not
            if (this.IsVacationDetailApproved(VacationDetailID))
            {
                result            = new Result();
                result.EnumType   = typeof(VacationsValidationEnum);
                result.EnumMember = VacationsValidationEnum.RejectedBeacuseOfAlreadyApproved.ToString();
                return(result);
            }
            #endregion

            #region Validate if this action is cancelling or not
            if (VacationDetail.VacationAction.VacationActionID == (int)VacationsActionsEnum.Cancel)
            {
                result            = new Result();
                result.EnumType   = typeof(VacationsValidationEnum);
                result.EnumMember = VacationsValidationEnum.RejectedBeacuseOfNoChanceCancelCancelling.ToString();
                return(result);
            }
            #endregion

            #region Delete vacation detail and update the main vacation data in HCM App And Time Attendance App

            //delete the vacation detail
            new VacationsDetailsDAL().Delete(VacationDetailID, this.LoginIdentity.EmployeeCodeID);

            // get last vacation detail to update the the main data of the vacation
            VacationsDetailsBLL FirstVacationDetail = new VacationsDetailsBLL().GetVacationsDetailsByVacationID(VacationDetail.Vacation.VacationID).FirstOrDefault();
            VacationsDetailsBLL LastVacationDetail  = new VacationsDetailsBLL().GetVacationsDetailsByVacationID(VacationDetail.Vacation.VacationID).LastOrDefault();
            if (LastVacationDetail == null) // thats mean no action more in details (created record was deleted) in this case we are going to delete main vacation data from HCM App and delete vacation also from Time Attendance App
            {
                new BaseVacationsBLL()
                {
                    VacationID    = VacationDetail.Vacation.VacationID,
                    LoginIdentity = this.LoginIdentity
                }.Remove();

                new TimeAttendanceBLL().DeleteEmployeeVacation(VacationDetail.Vacation.VacationID, this.LoginIdentity.EmployeeCodeNo);
            }
            else
            {
                new VacationsDAL().UpdateVacationDates(new Vacations()
                {
                    VacationID        = LastVacationDetail.Vacation.VacationID,
                    VacationStartDate = FirstVacationDetail.FromDate,
                    VacationEndDate   = LastVacationDetail.ToDate,
                    LastUpdatedDate   = DateTime.Now,
                    LastUpdatedBy     = this.LoginIdentity.EmployeeCodeID
                });

                new TimeAttendanceBLL().EditEmployeeVacation(VacationDetail.Vacation.VacationID, FirstVacationDetail.FromDate, LastVacationDetail.ToDate, this.LoginIdentity.EmployeeCodeNo);
            }

            result            = new Result();
            result.EnumType   = typeof(VacationsValidationEnum);
            result.EnumMember = VacationsValidationEnum.Done.ToString();
            return(result);

            #endregion
        }