public void SetUp() { _rules = new List <ILeaveRules>(); _rules.Add(new HRLeaveRules()); _rules.Add(new AccountsLeaveRules()); _leaveService = new LeaveService(_rules); }
public static void ShouldCalculateLeaveAllowed(int expected, PersonRoleWithJob[] personRoles) { var schoolYear = new DateTime(2018, 2, 21).SchoolYear(); var result = LeaveService.LeaveAllowed(LeaveType.Vacation, personRoles, schoolYear); Assert.Equal(expected, result); }
/// <summary> /// Initializes a new instance of the <see cref="HomeController" /> class. /// </summary> /// <param name="leaveService">The leave service.</param> /// <param name="timesheetService">The timesheet service.</param> /// <param name="lookupService">The lookup service.</param> /// <param name="releaseService">The release service.</param> public HomeController(LeaveService leaveService, TimesheetService timesheetService, LookupService lookupService, ReleaseService releaseService) { this.leaveService = leaveService; this.timesheetService = timesheetService; this.lookupService = lookupService; this.releaseService = releaseService; }
public JsonResult GetFiledForms() { string serverResponse = ""; var filedLeave = new List <LeaveFormModel>(); var filedOvertime = new List <OvertimeFormModel>(); if (UniversalHelpers.CurrentUser.Type == "USR") { filedLeave = LeaveService.GetLeavePerUser(out serverResponse); } else { filedLeave = LeaveService.GetAllLeave(out serverResponse); } if (UniversalHelpers.CurrentUser.Type == "USR") { filedOvertime = OvertimeService.GetOverTimePerUser(out serverResponse); } else { filedOvertime = OvertimeService.GetOverTimeAll(out serverResponse); } return(Json(new { leave = filedLeave, overtime = filedOvertime, errorMessage = serverResponse })); }
/// <summary> /// Display the leaves of the employees which have to be approved /// </summary> /// <returns>Employee list</returns> public IActionResult ApproveLeave() { try { int id = Convert.ToInt32(HttpContext.Session.GetInt32("id")); ViewBag.login = 1; LeaveService leaveService = new LeaveService(); List <Employee> employeeList = leaveService.DisplayApproveLeave(id); if (employeeList != null) { return(View(employeeList)); } else { return(RedirectToAction("Index", "Employee")); } } catch (Exception e) { ErrorViewModel errorView = new ErrorViewModel(); errorView.Message = "Error Occured while displaying approve leave"; errorView.Reason = e.Message; return(RedirectToAction("Error", "ErrorHandling", errorView)); } }
public LeaveCalculationsTests(ServicesFixture servicesFixture) { _sf = servicesFixture; _sf.DoOnce(f => f.SetupData()); _transaction = _sf.DbConnection.BeginTransaction(); _leaveService = _sf.Get <LeaveService>(); }
public ShowRequestDialog(DateRangeDTO dateRange, ShowRequest showRequest) { this._dateRange = dateRange; this._showRequest = showRequest; this.leaveService = new LeaveService(); this.flexibleHolidayService = new FlexibleHolidayService(); }
public JsonResult GetLeaveTypeDetail(Guid ID) { string serverResponse = ""; var days = LeaveService.GetMinDateForLeave(ID, out serverResponse); return(Json(new { days = days, errorMessage = serverResponse })); }
public JsonResult GetLeaveTypeDropdown() { string serverResponse = ""; var type = LeaveService.GetLeaveType(out serverResponse); return(Json(new { errorMessage = serverResponse, leaveType = type })); }
public LeaveRequestTests() { _servicesFixture = new ServicesFixture(); _leaveService = _servicesFixture.Get <LeaveService>(); _orgGroupRepository = _servicesFixture.Get <OrgGroupRepository>(); _dbConnection = _servicesFixture.Get <IDbConnection>(); _servicesFixture.SetupPeople(); }
public void ThrowsForNewRequestsWhenOverridingDays() { LeaveRequest request = GenerateRequest(); request.OverrideDays = true; Assert.Throws <UnauthorizedAccessException>(() => LeaveService.ThrowIfHrRequiredForUpdate(null, request, new List <Holiday>())); }
/// <summary> /// Cancel an applied leave of an employee /// </summary> /// <param name="leaveId">id of leave</param> /// <returns>Leave history without the canceled data</returns> public IActionResult DeleteLeave(int leaveId) { int id = Convert.ToInt32(HttpContext.Session.GetInt32("id")); LeaveService leaveService = new LeaveService(); leaveService.DeleteLeave(leaveId); return(RedirectToAction("LeaveHistory", "Employee")); }
public void ShouldMatchExpectedLeave(DateTime startDate, DateTime endDate, int expectedDays) { var leaveRequest = new LeaveRequest(startDate, endDate); leaveRequest.Days = leaveRequest.CalculateLength(); var result = LeaveService.TotalLeaveUsed(new[] { leaveRequest }); Assert.Equal(expectedDays, result); }
public JsonResult GetForApproval() { string serverResponse = ""; var leave = LeaveService.GetForApproval(out serverResponse); var ot = OvertimeService.GetForApproval(out serverResponse); return(Json(new { errorMessage = serverResponse, leave, ot })); }
public LeaveRequestTests(ServicesFixture sf) { _sf = sf; _leaveService = _sf.Get <LeaveService>(); _orgGroupRepository = _sf.Get <OrgGroupRepository>(); _sf.DoOnce(fixture => fixture.SetupPeople()); _transaction = _sf.DbConnection.BeginTransaction(); _serviceScope = _sf.ServiceProvider.CreateScope(); _scopeServiceProvider = _serviceScope.ServiceProvider; }
public IActionResult PostLeaveService(LeaveService leaveService) { using (var scope = new TransactionScope()) { Leave1.ApplyLeave(leaveService); scope.Complete(); CreatedAtAction(nameof(GetLeaveService), new { id = leaveService.EmpId }, leaveService); return(Ok()); } }
public JsonResult SaveLeaveForUser(LeaveFormModel leave, UserModel user) { string serverResponse = ""; if (leave != null) { LeaveService.SaveUpdateAdmin(leave, user, out serverResponse); } return(Json(new { errorMessage = serverResponse })); }
public void ThrowsIfChangingApproved() { LeaveRequest oldRequest = GenerateRequest(); LeaveRequest newRequest = oldRequest.Copy(); oldRequest.Approved = false; newRequest.Approved = true; var ex = Assert.Throws <UnauthorizedAccessException>(() => LeaveService.ThrowIfHrRequiredForUpdate(oldRequest, newRequest, new List <Holiday>())); Assert.Contains("approve", ex.Message); }
public bool CheckEligibility(LeaveRequest leaveRequest, LeaveService leaveService) { foreach (var rule in rules) { if (!rule.CheckEligibility(leaveRequest, leaveService)) { return(false); } } return(true); }
public void ThrowsErrorWhenPersonIsInvalid() { LeaveRequest oldRequest = GenerateRequest(); LeaveRequest newRequest = oldRequest.Copy(); newRequest.PersonId = Guid.NewGuid(); var ex = Assert.Throws <UnauthorizedAccessException>(() => LeaveService.ThrowIfHrRequiredForUpdate(oldRequest, newRequest, new List <Holiday>())); ex.Message.ShouldContain("change the person"); }
public JsonResult CancelLeave(LeaveFormModel leave) { string serverResponse = ""; leave.Status = "X"; if (leave != null) { LeaveService.SaveUpdate(leave, out serverResponse); } return(Json(new { errorMessage = serverResponse })); }
public LeavePolicy GetLeavePolicy(string type, LeaveRequest leaveRequest, LeaveService leaveService) { if (type == "Assignment") { return(new LeaveAssignmentPolicy()); } else if (type == "Request") { return(new LeaveRequestPolicy()); } return(null); }
public void ThrowIfCalculationIsOff() { LeaveRequest request = GenerateRequest(); //16th is a friday request.StartDate = new DateTime(2018, 3, 14); request.EndDate = new DateTime(2018, 3, 16); //should be 3 days request.Days = 2; Assert.Throws <ArgumentException>(() => LeaveService.ThrowIfHrRequiredForUpdate(null, request, new List <Holiday>())); request.Days.ShouldBe(2); }
public IActionResult ApplyLeave(Leave leave) { bool isSuccess = false; try { int id = Convert.ToInt32(HttpContext.Session.GetInt32("id")); ViewBag.login = 1; leave.EmpID = id; leave.Count = leave.EndDate.Subtract(leave.StartDate).Days; if (leave.Count >= 0) { int weekendCountCheck = CheckIfWeekendsAreThere(leave); leave.Count = (leave.Count - weekendCountCheck) + 1; } if (leave.Count == 0) { ViewBag.holidays = 1; return(View()); } if (leave.Count < 0) { ViewBag.errorEntry = 1; return(View()); } else { LeaveService leaveService = new LeaveService(); int returnValue = leaveService.AddLeaveDetails(leave); if (returnValue == 1) { return(RedirectToAction("Index", "Employee")); } else { ViewBag.IsSuccess = isSuccess; } } return(View()); } catch (Exception e) { ErrorViewModel errorView = new ErrorViewModel(); errorView.Message = "Error Occured while Applying Leave"; errorView.Reason = e.Message; return(RedirectToAction("Error", "ErrorHandling", errorView)); } }
public void ThrowsWhenChangingDaysWhenOverriden() { LeaveRequest oldRequest = GenerateRequest(); oldRequest.OverrideDays = true; LeaveRequest newRequest = oldRequest.Copy(); newRequest.Days++; var ex = Assert.Throws <UnauthorizedAccessException>(() => LeaveService.ThrowIfHrRequiredForUpdate(oldRequest, newRequest, new List <Holiday>())); Assert.Contains("modify the length", ex.Message); }
public void ThrowsWhenModifyingApprovedLeave() { LeaveRequest oldRequest = GenerateRequest(); oldRequest.Approved = true; Assert.Throws <UnauthorizedAccessException>(() => LeaveService.ThrowIfHrRequiredForUpdate(oldRequest, oldRequest, new List <Holiday>())); oldRequest.Approved = false; Assert.Throws <UnauthorizedAccessException>(() => LeaveService.ThrowIfHrRequiredForUpdate(oldRequest, oldRequest, new List <Holiday>())); oldRequest.Approved = null; //doesn't throw LeaveService.ThrowIfHrRequiredForUpdate(oldRequest, oldRequest, new List <Holiday>()); }
public void AcceptMissmatchedCalculationForHalfDays() { LeaveRequest oldRequest = GenerateRequest(); //16th is a friday oldRequest.StartDate = new DateTime(2018, 3, 16); oldRequest.EndDate = new DateTime(2018, 3, 16); oldRequest.Days = oldRequest.CalculateLength(); LeaveRequest newRequest = oldRequest.Copy(); newRequest.Days = 0.5m; //does not throw LeaveService.ThrowIfHrRequiredForUpdate(oldRequest, newRequest, new List <Holiday>()); }
public void ThrowsWhenChangingStartAndEndForOverridenDays() { LeaveRequest oldRequest = GenerateRequest(); oldRequest.OverrideDays = true; LeaveRequest newRequest = oldRequest.Copy(); newRequest.EndDate += TimeSpan.FromDays(4); var ex = Assert.Throws <UnauthorizedAccessException>(() => LeaveService.ThrowIfHrRequiredForUpdate(oldRequest, newRequest, new List <Holiday>())); Assert.Contains("modify the start or end", ex.Message); }
public ActionResult PutLeaveService(string id, [FromBody] LeaveService leaveService) { if (leaveService == null) { return(BadRequest()); } LeaveService _leav = Leave1.GetLeave(id); if (_leav == null) { return(NotFound()); } Leave1.UpdateEmployee(_leav, leaveService); return(NoContent()); }
public void DontMissmatchedCalculationForHalfDaysOnWeekend() { LeaveRequest oldRequest = GenerateRequest(); //17th is a saturday oldRequest.StartDate = new DateTime(2018, 3, 17); oldRequest.EndDate = new DateTime(2018, 3, 17); oldRequest.Days = oldRequest.CalculateLength(); LeaveRequest newRequest = oldRequest.Copy(); newRequest.Days = 0.5m; //does not throw Assert.Throws <UnauthorizedAccessException>(() => LeaveService.ThrowIfHrRequiredForUpdate(oldRequest, newRequest, new List <Holiday>())); }
public void ShouldAllowOverridingLeaveUsed() { var startDate = new DateTime(2015, 5, 4); var endDate = new DateTime(2015, 5, 5); var result = LeaveService.TotalLeaveUsed(new[] { new LeaveRequest(startDate, endDate) { OverrideDays = true, Days = 5 } }); Assert.Equal(2, startDate.BusinessDaysUntil(endDate)); Assert.Equal(5, result); }
/// <summary> /// Initializes a new instance of the <see cref="TeamLeavesController"/> class. /// </summary> /// <param name="leaveService">The leave service.</param> /// <param name="lookupService">The lookup service.</param> /// <param name="developerService">The developer service.</param> public TeamLeavesController(LeaveService leaveService, LookupService lookupService, DeveloperService developerService) { this.leaveService = leaveService; this.lookupService = lookupService; this.developerService = developerService; }
/// <summary> /// Initializes a new instance of the <see cref="AuthenticationController" /> class. /// </summary> /// <param name="developerService">The developer service.</param> /// <param name="leaveService">The leave service.</param> /// <param name="timesheetService">The timesheet service.</param> /// <param name="releaseService">The release service.</param> /// <param name="lookupService">The lookup service.</param> public AuthenticationController(DeveloperService developerService, LeaveService leaveService, TimesheetService timesheetService, ReleaseService releaseService, LookupService lookupService) { this.developerService = developerService; this.leaveService = leaveService; this.timesheetService = timesheetService; this.releaseService = releaseService; this.lookupService = lookupService; }
/// <summary> /// Initializes a new instance of the <see cref="LeaveController" /> class. /// </summary> /// <param name="leaveService">The leave service.</param> public LeaveController(LeaveService leaveService) { this.leaveService = leaveService; }
/// <summary> /// Initializes a new instance of the AssignmentsController class. /// </summary> /// <param name="developerService">The developer service.</param> /// <param name="lookupService">The lookup service.</param> /// <param name="teamEngagementService">The team engagement service</param> /// <param name="loanResourceService">The loan resource service.</param> /// <param name="leaveService">The leaves resource service.</param> public AssignmentsController(DeveloperService developerService, LookupService lookupService, TeamEngagementService teamEngagementService, LoanResourceService loanResourceService, LeaveService leaveService) { this.developerService = developerService; this.lookupService = lookupService; this.teamEngagementService = teamEngagementService; this.loanResourceService = loanResourceService; this.leaveService = leaveService; }
/// <summary> /// Initializes a new instance of the <see cref="LeaveAdjustmentController"/> class. /// </summary> /// <param name="leaveService">The leave service.</param> public LeaveAdjustmentController(LeaveService leaveService) { this.leaveService = leaveService; }