public HttpResponseMessage AddEndOfServiceVacations(EndOfServicesViewModel EndOfServiceVM) { EndOfServicesVacationsBLL EndOfServiceVacation = new EndOfServicesVacationsBLL() { EndOfService = new EndOfServicesBLL() { EndOfServiceID = EndOfServiceVM.EndOfServiceID }, VacationStartDate = (DateTime)EndOfServiceVM.EndOfServiceVacationStartDate, VacationEndDate = (DateTime)EndOfServiceVM.EndOfServiceVacationEndDate, VacationType = EndOfServiceVM.EndOfServiceVacationType, LoginIdentity = UserIdentity }; Result result = EndOfServiceVacation.Add(); if ((System.Type)result.EnumType == typeof(EndOfServicesVacationsValidationEnum)) { if (result.EnumMember == EndOfServicesVacationsValidationEnum.RejectedBecauseOfVacationEndDateBiggerThanEndOfServiceDate.ToString()) { throw new CustomException(Resources.Globalization.ValidationVacationStartDateBiggerThanEndOfServiceDateText); } } return(new HttpResponseMessage(HttpStatusCode.OK)); }
public void GetVacationBalances(string EndOfServiceID, out string TotalDeservedBalance, out string TotalConsumedBalance, out string TotalRemainingBalance, out string TotalDeservedRemainingBalance) { int endOfServiceID = int.Parse(EndOfServiceID); EndOfServicesBLL EndOfServices = new EndOfServicesBLL().GetByEndOfServiceID(endOfServiceID); //--======== Culculate Noraml vacation . var Vacation = GenericFactoryPattern <BaseVacationsBLL, NormalVacationsBLL> .CreateInstance(); Vacation.VacationStartDate = Convert.ToDateTime(EndOfServices.EndOfServiceDate.ToString(ConfigurationManager.AppSettings["DateFormat"]), new CultureInfo("ar-SA")); //EndOfServices.EndOfServiceDate; int UmAlQuraYear, UmAlQuraMonth, UmAlQuraDay; UmAlQuraYear = Globals.Calendar.GetUmAlQuraYear(EndOfServices.EndOfServiceDate); UmAlQuraMonth = Globals.Calendar.GetUmAlQuraMonth(EndOfServices.EndOfServiceDate); UmAlQuraDay = Globals.Calendar.GetUmAlQuraDay(EndOfServices.EndOfServiceDate); ((NormalVacationsBLL)Vacation).GetVacationBalances(EndOfServices.EmployeeCareerHistory.EmployeeCode.EmployeeCodeID, UmAlQuraYear, UmAlQuraMonth, UmAlQuraDay); //--======== Culculate EndOfService Vacation . int TotalEndOfServiceVacationsConsumedBalance = 0; List <EndOfServicesVacationsBLL> EndOfServicesVacationsList = new EndOfServicesVacationsBLL().GetByEndOfServiceID(endOfServiceID); foreach (EndOfServicesVacationsBLL EndOfServiceVacation in EndOfServicesVacationsList) { if (EndOfServiceVacation.VacationType.VacationTypeID == (int)VacationsTypesEnum.Normal) { TotalEndOfServiceVacationsConsumedBalance += EndOfServiceVacation.VacationPeriod; } } int MaxNormalCompensation = new EndOfServicesVacationsBLL().MaxNormalCompensation; TotalDeservedBalance = (Vacation as NormalVacationsBLL).TotalDeservedBalance.ToString(); TotalConsumedBalance = ((Vacation as NormalVacationsBLL).TotalConsumedBalance + TotalEndOfServiceVacationsConsumedBalance).ToString(); TotalRemainingBalance = ((Vacation as NormalVacationsBLL).TotalRemainingBalance - TotalEndOfServiceVacationsConsumedBalance).ToString(); TotalDeservedRemainingBalance = int.Parse(TotalRemainingBalance) >= MaxNormalCompensation?MaxNormalCompensation.ToString() : TotalRemainingBalance; }
public JsonResult GetEndOfServicesVacationsByEndOfServiceID(int id) { List <EndOfServicesVacationsBLL> EndOfServicesVacationsList = new EndOfServicesVacationsBLL().GetByEndOfServiceID(id); return(Json(new { data = EndOfServicesVacationsList }, JsonRequestBehavior.AllowGet)); }