/// <summary> /// Cancels the leave. /// </summary> /// <param name="employeeId">The employee identifier.</param> /// <returnsThe Outcome.</returns> public DataOperationOutcome CancelLeave(int employeeId) { var context = new LeavePortalEntities(); var leaveRequestOutcome = context.LeaveRequests.SingleOrDefault(x => x.EmployeeId == employeeId && x.IsPending == true); leaveRequestOutcome.IsPending = false; leaveRequestOutcome.LeaveCancelled = true; context.SaveChanges(); return(DataOperationOutcome.Success); }
/// <summary> /// Commits the leave balance. /// </summary> /// <param name="employeeId">The employee identifier.</param> /// <param name="leaveBalance">The leave balance.</param> /// <param name="approved">if set to <c>true</c> [approved].</param> /// <returns> /// Teh DataOperationOutcome. /// </returns> public DataOperationOutcome CommitLeaveBalance(int employeeId, decimal leaveBalance, bool approved) { var context = new LeavePortalEntities(); var leaveBalanceOutcome = context.LeaveBalances.SingleOrDefault(x => x.EmployeeId == employeeId); var leaveRequestOutcome = context.LeaveRequests.SingleOrDefault(x => x.EmployeeId == employeeId && x.IsPending == true); leaveBalanceOutcome.Balance = leaveBalance; leaveRequestOutcome.IsApproved = approved; leaveRequestOutcome.IsPending = false; context.SaveChanges(); return(DataOperationOutcome.Success); }
/// <summary> /// Updates the leave request. /// </summary> /// <param name="employeeId">The employee identifier.</param> /// <param name="fromDate">From date.</param> /// <param name="toDate">To date.</param> /// <param name="daysRequested">The days requested.</param> /// <param name="remainingBalance">The remaining balance.</param> /// <param name="leaveTypeId">The leave type identifier.</param> /// <param name="comments">The comments.</param> /// <param name="supervisorId">The supervisor identifier.</param> /// <returns>The DataOperationOutcome</returns> public DataOperationOutcome UpdateLeaveRequest(int employeeId, DateTime fromDate, DateTime toDate, decimal daysRequested, decimal remainingBalance, int leaveTypeId, string comments, int supervisorId) { var context = new LeavePortalEntities(); var leaveRequest = context.LeaveRequests.SingleOrDefault(x => x.EmployeeId == employeeId && x.IsPending == true); leaveRequest.FromDate = fromDate; leaveRequest.ToDate = toDate; leaveRequest.LeaveRequestedInDays = daysRequested; leaveRequest.RemainingLeaveBalance = remainingBalance; leaveRequest.LeaveTypeId = leaveTypeId; leaveRequest.Comments = comments; context.SaveChanges(); return(DataOperationOutcome.Success); }
/// <summary> /// Adds the new leave request. /// </summary> /// <param name="employeeId">The employee identifier.</param> /// <param name="fromDate">From date.</param> /// <param name="toDate">To date.</param> /// <param name="daysRequested">The days requested.</param> /// <param name="remainingBalance">The remaining balance.</param> /// <param name="leaveTypeId">The leave type identifier.</param> /// <param name="comments">The comments.</param> /// <param name="supervisorId">The supervisor identifier.</param> /// <returns> /// The DataOperationOutcome. /// </returns> public DataOperationOutcome AddNewLeaveRequest(int employeeId, DateTime fromDate, DateTime toDate, decimal daysRequested, decimal remainingBalance, int leaveTypeId, string comments, int supervisorId) { var context = new LeavePortalEntities(); var addleaveRequest = new LeaveRequest { FromDate = fromDate, ToDate = toDate, LeaveRequestedInDays = daysRequested, RemainingLeaveBalance = remainingBalance, IsPending = true, EmployeeId = employeeId, ApprovedBy = supervisorId, LeaveTypeId = leaveTypeId, Comments = comments, LeaveCancelled = false, DateRequested = DateTime.Now }; context.LeaveRequests.Add(addleaveRequest); context.SaveChanges(); return(DataOperationOutcome.Success); }