Ejemplo n.º 1
0
        public long CreateRequestDay(long requestId, DateTime ptoDayDate, long requestTypeID)
        {
            long returnValue;

            try
            {
                using (var context = new PTOMEntities())
                {
                    returnValue = GetSequenceNextValue(context, "PTOMS.PTO_DAY_ID_SQ");
                    var d = new PTO_DAY
                    {
                        PTO_DAY_DATE    = ptoDayDate,
                        PTO_DAY_ID      = returnValue,
                        PTO_REQUEST_ID  = requestId,
                        REQUEST_TYPE_ID = requestTypeID
                    };
                    context.PTO_DAY.AddObject(d);
                    context.SaveChanges();
                }
            }
            catch (Exception ex)
            {
                LoggingHelper.LogServiceMessage(LoggingHelper.MessageType.Error, string.Empty, ex);
                throw;
            }

            return(returnValue);
        }
Ejemplo n.º 2
0
        public void UpdateEmployee(long employeeId, bool isAdmin, string displayName, string email, DateTime hireDate, DateTime anniversaryDate, long approverId)
        {
            try
            {
                using (var context = new PTOMEntities())
                {
                    var item = context.EMPLOYEE.FirstOrDefault(emp => emp.EMPLOYEE_ID == employeeId);
                    if (item != null)
                    {
                        item.DISPLAY_NAME         = displayName;
                        item.IS_ADMIN             = isAdmin ? "Y" : "N";
                        item.EMAIL                = email;
                        item.HIRE_DATE            = hireDate;
                        item.ANNIVERSARY_DATE     = anniversaryDate;
                        item.APPROVER_EMPLOYEE_ID = approverId;

                        context.SaveChanges();
                    }
                }
            }
            catch (Exception ex)
            {
                LoggingHelper.LogServiceMessage(LoggingHelper.MessageType.Error, string.Empty, ex);
                throw;
            }
        }
Ejemplo n.º 3
0
        public long CreateRequest(long userId, long approverEmployeeId, string comment, long ptoCycleID)
        {
            long returnValue;

            try
            {
                using (var context = new PTOMEntities())
                {
                    returnValue = GetSequenceNextValue(context, "PTOMS.PTO_REQUEST_ID_SQ");
                    var r = new PTO_REQUEST
                    {
                        APPROVER_EMPLOYEE_ID = approverEmployeeId,
                        EMPLOYEE_ID          = userId,
                        PTO_COMMENT          = comment,
                        PTO_REQUEST_ID       = returnValue,
                        REQUEST_DATE         = DateTime.Now,
                        PTO_CYCLE_ID         = ptoCycleID,
                        STATUS = RequestStatus.Pending.ToString()
                    };
                    context.PTO_REQUEST.AddObject(r);
                    context.SaveChanges();
                }
            }
            catch (Exception ex)
            {
                LoggingHelper.LogServiceMessage(LoggingHelper.MessageType.Error, string.Empty, ex);
                throw;
            }

            return(returnValue);
        }
Ejemplo n.º 4
0
        public long CreateRollover(long employeeId, decimal?hours)
        {
            long returnvalue;

            try
            {
                using (var context = new PTOMEntities())
                {
                    returnvalue = GetSequenceNextValue(context, "PTOMS.ROLLOVER_ID_SQ");
                    var r = new ROLLOVER
                    {
                        ROLLOVER_ID  = returnvalue,
                        EMPLOYEE_ID  = employeeId,
                        HOURS        = hours,
                        PTO_CYCLE_ID = CurrentCycle.PTOCycleID.Value
                    };
                    context.ROLLOVER.AddObject(r);
                    context.SaveChanges();
                }
            }
            catch (Exception ex)
            {
                LoggingHelper.LogServiceMessage(LoggingHelper.MessageType.Error, string.Empty, ex);
                throw;
            }

            return(returnvalue);
        }
Ejemplo n.º 5
0
        public long CreateEmployee(string userName, string displayName, bool isAdmin, string email, DateTime hireDate, DateTime anniversaryDate, long approverId)
        {
            long returnValue;

            try
            {
                using (var context = new PTOMEntities())
                {
                    returnValue = GetSequenceNextValue(context, "PTOMS.EMPLOYEE_ID_SQ");
                    var employee = new EMPLOYEE
                    {
                        EMPLOYEE_ID          = returnValue,
                        USERNAME             = userName.ToLower(),
                        DISPLAY_NAME         = displayName,
                        IS_ADMIN             = isAdmin ? "Y" : "N",
                        EMAIL                = email,
                        HIRE_DATE            = hireDate,
                        ANNIVERSARY_DATE     = anniversaryDate,
                        APPROVER_EMPLOYEE_ID = approverId
                    };
                    context.EMPLOYEE.AddObject(employee);
                    context.SaveChanges();
                }
            }
            catch (Exception ex)
            {
                LoggingHelper.LogServiceMessage(LoggingHelper.MessageType.Error, string.Empty, ex);
                throw;
            }

            return(returnValue);
        }
Ejemplo n.º 6
0
        public long?CreateHoliday(DateTime date, string name, long ptoCycle)
        {
            long returnValue;

            try
            {
                using (var context = new PTOMEntities())
                {
                    returnValue = GetSequenceNextValue(context, "PTOMS.HOLIDAY_ID_SQ");
                    var holiday = new HOLIDAY
                    {
                        HOLIDAY_ID   = returnValue,
                        NAME         = name,
                        HOLIDAY_DATE = date,
                        PTO_CYCLE    = ptoCycle
                    };
                    context.HOLIDAY.AddObject(holiday);
                    context.SaveChanges();
                }
            }
            catch (Exception ex)
            {
                LoggingHelper.LogServiceMessage(LoggingHelper.MessageType.Error, string.Empty, ex);
                throw;
            }

            return(returnValue);
        }
Ejemplo n.º 7
0
 public void DeleteRequest(long requestId)
 {
     try
     {
         using (var context = new PTOMEntities())
         {
             var REQ = context.PTO_REQUEST.FirstOrDefault(x => x.PTO_REQUEST_ID == requestId);
             if (REQ != null)
             {
                 context.DeleteObject(REQ);
                 context.SaveChanges();
             }
         }
     }
     catch (Exception ex)
     {
         LoggingHelper.LogServiceMessage(LoggingHelper.MessageType.Error, string.Empty, ex);
         throw;
     }
 }
Ejemplo n.º 8
0
 public void DeleteEmployee(long employeeId)
 {
     try
     {
         using (var context = new PTOMEntities())
         {
             var EMPLOYEE = context.EMPLOYEE.FirstOrDefault(emp => emp.EMPLOYEE_ID == employeeId);
             if (EMPLOYEE != null)
             {
                 context.DeleteObject(EMPLOYEE);
                 context.SaveChanges();
             }
         }
     }
     catch (Exception ex)
     {
         LoggingHelper.LogServiceMessage(LoggingHelper.MessageType.Error, string.Empty, ex);
         throw;
     }
 }
Ejemplo n.º 9
0
 public void UpdateRollover(long employeeId, decimal?hours)
 {
     try
     {
         using (var context = new PTOMEntities())
         {
             var r = context.ROLLOVER.FirstOrDefault(x => x.EMPLOYEE_ID == employeeId);
             if (r != null)
             {
                 r.HOURS        = hours;
                 r.PTO_CYCLE_ID = CurrentCycle.PTOCycleID.Value;
                 context.SaveChanges();
             }
         }
     }
     catch (Exception ex)
     {
         LoggingHelper.LogServiceMessage(LoggingHelper.MessageType.Error, string.Empty, ex);
         throw;
     }
 }
Ejemplo n.º 10
0
 private void UpdateApprover(long employeeId, bool Approver)
 {
     try
     {
         using (var context = new PTOMEntities())
         {
             var employee = context.EMPLOYEE.FirstOrDefault(h => h.EMPLOYEE_ID == employeeId);
             if (employee != null)
             {
                 employee.IS_APPROVER = Approver ? "Y":"N";
                 context.SaveChanges();
             }
             ;
         }
     }
     catch (Exception ex)
     {
         LoggingHelper.LogServiceMessage(LoggingHelper.MessageType.Error, string.Empty, ex);
         throw;
     }
 }
Ejemplo n.º 11
0
 public void EditRequestDay(long requestId, DateTime ptoDayDate, long requestTypeID, long ptoDayID)
 {
     try
     {
         using (var context = new PTOMEntities())
         {
             var d = context.PTO_DAY.FirstOrDefault(day => day.PTO_DAY_ID == ptoDayID);
             if (d != null)
             {
                 d.PTO_DAY_DATE    = ptoDayDate;
                 d.PTO_REQUEST_ID  = requestId;
                 d.REQUEST_TYPE_ID = requestTypeID;
                 context.SaveChanges();
             }
         }
     }
     catch (Exception ex)
     {
         LoggingHelper.LogServiceMessage(LoggingHelper.MessageType.Error, string.Empty, ex);
         throw;
     }
 }
Ejemplo n.º 12
0
        public void UpdateEmployeeTeams(long employeeId, long teamId)
        {
            try
            {
                using (var context = new PTOMEntities())
                {
                    var item = context.EMPLOYEE_TEAM.FirstOrDefault(x => x.EMPLOYEE_ID == employeeId);
                    if (item != null)
                    {
                        item.EMPLOYEE_ID = employeeId;
                        item.TEAM_ID     = teamId;

                        context.SaveChanges();
                    }
                }
            }
            catch (Exception ex)
            {
                LoggingHelper.LogServiceMessage(LoggingHelper.MessageType.Error, string.Empty, ex);
                throw;
            }
        }
Ejemplo n.º 13
0
 public void AssignEmployeeToTeam(long employeeId, long teamId)
 {
     try
     {
         using (var context = new PTOMEntities())
         {
             var t = new EMPLOYEE_TEAM
             {
                 EMPLOYEE_ID      = employeeId,
                 TEAM_ID          = teamId,
                 EMPLOYEE_TEAM_ID = GetSequenceNextValue(context, "PTOMS.EMPLOYEE_TEAM_ID_SQ")
             };
             context.EMPLOYEE_TEAM.AddObject(t);
             context.SaveChanges();
         }
     }
     catch (Exception ex)
     {
         LoggingHelper.LogServiceMessage(LoggingHelper.MessageType.Error, string.Empty, ex);
         throw;
     }
 }
Ejemplo n.º 14
0
 public void UpdateRequest(long requestID, long approverId, string comment, RequestStatus status, string requestChangeComment, DateTime?requestChangeDate)
 {
     try
     {
         using (var context = new PTOMEntities())
         {
             var r = context.PTO_REQUEST.FirstOrDefault(REQ => REQ.PTO_REQUEST_ID == requestID);
             if (r != null)
             {
                 r.APPROVER_EMPLOYEE_ID = approverId;
                 r.PTO_COMMENT          = comment;
                 r.STATUS = status.ToString();
                 r.STATUS_CHANGE_COMMENT = requestChangeComment;
                 r.STATUS_CHANGE_DATE    = requestChangeDate;
                 context.SaveChanges();
             }
         }
     }
     catch (Exception ex)
     {
         LoggingHelper.LogServiceMessage(LoggingHelper.MessageType.Error, string.Empty, ex);
         throw;
     }
 }
Ejemplo n.º 15
0
        public void UpdateHoliday(long holidayID, DateTime date, string name, long ptoCycle)
        {
            try
            {
                using (var context = new PTOMEntities())
                {
                    var holiday = context.HOLIDAY.FirstOrDefault(h => h.HOLIDAY_ID == holidayID);
                    if (holiday != null)
                    {
                        holiday.HOLIDAY_DATE = date;
                        holiday.NAME         = name;
                        holiday.PTO_CYCLE    = ptoCycle;

                        context.SaveChanges();
                    }
                    ;
                }
            }
            catch (Exception ex)
            {
                LoggingHelper.LogServiceMessage(LoggingHelper.MessageType.Error, string.Empty, ex);
                throw;
            }
        }