public HttpResponseMessage GetVacationBalanceByEmployeeCodeNo(VacationsTypesEnum VacationType, string EmployeeCodeNo) { if (string.IsNullOrEmpty(EmployeeCodeNo)) { return(Request.CreateResponse(HttpStatusCode.BadRequest)); } EmployeesCodesBLL emp = new EmployeesCodesBLL().GetByEmployeeCodeNo(EmployeeCodeNo); if (emp != null) { BaseVacationsBLL Vacation = GenericFactoryPattern <BaseVacationsBLL, NormalVacationsBLL> .CreateInstance(); DateTime CurrentDate = DateTime.Now.Date; int MaturityYearFromCurrentDate = Globals.Calendar.GetUmAlQuraYear(CurrentDate); int MaturityMonthFromCurrentDate = Globals.Calendar.GetUmAlQuraMonth(CurrentDate); int MaturityDayFromCurrentDate = Globals.Calendar.GetUmAlQuraDay(CurrentDate); ((NormalVacationsBLL)Vacation).GetVacationBalances(emp.EmployeeCodeID, MaturityYearFromCurrentDate, MaturityMonthFromCurrentDate, MaturityDayFromCurrentDate); return(Request.CreateResponse(HttpStatusCode.OK, (NormalVacationsBLL)Vacation)); //return Request.CreateResponse(HttpStatusCode.OK, new //{ // EmployeeCodeID = ((NormalVacationsBLL)Vacation).EmployeeCareerHistory.EmployeeCode.EmployeeCodeID, // EmployeeCodeNo = ((NormalVacationsBLL)Vacation).EmployeeCareerHistory.EmployeeCode.EmployeeCodeNo, // EmployeeNameAr = ((NormalVacationsBLL)Vacation).EmployeeCareerHistory.EmployeeCode.Employee.EmployeeNameAr, // DeservedOldBalance = ((NormalVacationsBLL)Vacation).DeservedOldBalance, // ConsumedOldBalance = ((NormalVacationsBLL)Vacation).ConsumedOldBalance, // RemainingOldBalance = ((NormalVacationsBLL)Vacation).RemainingOldBalance, // DeservedCurrentBalance = ((NormalVacationsBLL)Vacation).DeservedCurrentBalance, // ConsumedCurrentBalance = ((NormalVacationsBLL)Vacation).ConsumedCurrentBalance, // ExpiredCurrentBalance = ((NormalVacationsBLL)Vacation).ExpiredCurrentBalance, // RemainingCurrentBalance = ((NormalVacationsBLL)Vacation).RemainingCurrentBalance, // TotalDeservedBalance = ((NormalVacationsBLL)Vacation).TotalDeservedBalance, // TotalConsumedBalance = ((NormalVacationsBLL)Vacation).TotalConsumedBalance, // TotalRemainingBalance = ((NormalVacationsBLL)Vacation).TotalRemainingBalance, // TotalConsumedSeparatedDays = ((NormalVacationsBLL)Vacation).TotalConsumedSeparatedDays, // InAdvanceBalance = ((NormalVacationsBLL)Vacation).InAdvanceBalance, // TotalAvailableVacationBalance = ((NormalVacationsBLL)Vacation).TotalAvailableVacationBalance, //}.ToXml()); } else { return(Request.CreateResponse(HttpStatusCode.BadRequest, "Employee not found!")); } }
/// <summary> /// To send new vacation data of employee to Time Attendance App /// </summary> /// <param name="EmployeeCodeNo"></param> /// <param name="VacationType"></param> /// <param name="VacationStartDate"></param> /// <param name="VacationEndDate"></param> /// <param name="CreatedBy"></param> /// <param name="CreatedDate"></param> /// <param name="VacationID"></param> /// <returns></returns> public Result AddEmployeeVacation(int VacationID, string EmployeeCodeNo, VacationsTypesEnum VacationType, DateTime VacationStartDate, DateTime VacationEndDate, string CreatedBy, DateTime CreatedDate) { try { Result result = new Result(); result.EnumType = typeof(VacationsValidationEnum); AddEmployeeVacation EmployeeVacationDTO = new AddEmployeeVacation() { EmployeeCode = EmployeeCodeNo, HCMVacationTypeID = (int)VacationType, HCMVacationID = VacationID, StartDate = VacationStartDate, EndDate = VacationEndDate, UserEmployeeCodeNo = CreatedBy, CreatedDate = CreatedDate, ApprovedByEmployeeCodeNo = CreatedBy, ApprovedDate = CreatedDate }; var PostTask = client.PostAsJsonAsync <AddEmployeeVacation>("EmployeeVacation", EmployeeVacationDTO).Result; if (PostTask.IsSuccessStatusCode) { result.EnumMember = VacationsValidationEnum.Done.ToString(); } else { result.EnumMember = VacationsValidationEnum.RejectedBecauseOfErrorInTimeAttendanceApp.ToString(); } return(result); } catch (Exception) { throw; } }