public HttpResponseMessage CreateOverTimeDetail(OverTimesViewModel OverTimeVM) { List <OverTimesDetailsBLL> OverTimeEmployeesList = GetOverTimeDetailsFromSession(); if (string.IsNullOrEmpty(OverTimeVM.OverTimeDetailRequest.EmployeeCareerHistory.EmployeeCode.EmployeeCodeNo)) { throw new CustomException(Resources.Globalization.RequiredEmployeeCodeNoText); } else if (OverTimeEmployeesList.FindIndex(e => e.EmployeeCareerHistory.EmployeeCode.EmployeeCodeNo.Equals(OverTimeVM.OverTimeDetailRequest.EmployeeCareerHistory.EmployeeCode.EmployeeCodeNo)) > -1) { throw new CustomException(Resources.Globalization.ValidationEmployeeAlreadyExistText); } DateTime StartDate, EndDate; StartDate = OverTimeVM.OverTimeStartDate; EndDate = (DateTime)OverTimeVM.OverTimeEndDate; OverTimesBLL overtime = new OverTimesBLL() { OverTimeStartDate = StartDate, OverTimeEndDate = EndDate, OverTimesDays = GetOverTimeDays(OverTimeVM.OverTimesDays) }; Result result = new OverTimesDetailsBLL() { OverTime = overtime, EmployeeCareerHistory = new EmployeesCareersHistoryBLL() { EmployeeCareerHistoryID = OverTimeVM.OverTimeDetailRequest.EmployeeCareerHistory.EmployeeCareerHistoryID, EmployeeCode = new EmployeesCodesBLL() { EmployeeCodeID = OverTimeVM.OverTimeDetailRequest.EmployeeCareerHistory.EmployeeCode.EmployeeCodeID } } }.IsValid(); if (result.EnumMember == OverTimeValidationEnum.Done.ToString()) { OverTimeEmployeesList.Add(OverTimeVM.OverTimeDetailRequest); Session["OverTimesEmployees"] = OverTimeEmployeesList; } else if (result.EnumMember == OverTimeValidationEnum.RejectedBecauseOfOverTimeDatesMustBeInSameFinancialYear.ToString()) { FinancialYearsBLL FinancialYearBLL = (FinancialYearsBLL)result.Entity; throw new CustomException(Resources.Globalization.ValidationOverTimeDatesMustBeInSameFinancialYearText + " NewLine " + Resources.Globalization.FinancialYearInfoText + FinancialYearBLL.FinancialYear + " NewLine " + Resources.Globalization.FinancialYearStartDateText + FinancialYearBLL.FinancialYearStartDate.Date.ToString(System.Configuration.ConfigurationManager.AppSettings["DateFormat"]) + " NewLine " + Resources.Globalization.FinancialYearEndDateText + FinancialYearBLL.FinancialYearEndDate.Date.ToString(System.Configuration.ConfigurationManager.AppSettings["DateFormat"])); } Classes.Helpers.CommonHelper.ConflictValidationMessage(result); return(new HttpResponseMessage(HttpStatusCode.OK)); }
public HttpResponseMessage CreateOverTimeDetailDB(OverTimesViewModel OverTimeVM) { if (string.IsNullOrEmpty(OverTimeVM.OverTimeDetailRequest.EmployeeCareerHistory.EmployeeCode.EmployeeCodeNo)) { throw new CustomException(Resources.Globalization.RequiredEmployeeCodeNoText); } DateTime StartDate, EndDate; StartDate = OverTimeVM.OverTimeStartDate; EndDate = (DateTime)OverTimeVM.OverTimeEndDate; OverTimesBLL overtime = new OverTimesBLL() { OverTimeID = OverTimeVM.OverTimeID, OverTimeStartDate = OverTimeVM.OverTimeStartDate, OverTimeEndDate = (DateTime)OverTimeVM.OverTimeEndDate }; OverTimesDetailsBLL overTimesDetail = new OverTimesDetailsBLL() { OverTime = overtime, EmployeeCareerHistory = new EmployeesCareersHistoryBLL() { EmployeeCareerHistoryID = OverTimeVM.OverTimeDetailRequest.EmployeeCareerHistory.EmployeeCareerHistoryID, EmployeeCode = new EmployeesCodesBLL() { EmployeeCodeID = OverTimeVM.OverTimeDetailRequest.EmployeeCareerHistory.EmployeeCode.EmployeeCodeID } }, LoginIdentity = new EmployeesCodesBLL() { EmployeeCodeID = int.Parse(Session["EmployeeCodeID"].ToString()) } }; Result result = overTimesDetail.IsValid(); if (result.EnumMember == OverTimeValidationEnum.Done.ToString()) { result = new OverTimesDetailsBLL().Add(overTimesDetail); } else if (result.EnumMember == OverTimeValidationEnum.RejectedBecauseOfOverTimeDatesMustBeInSameFinancialYear.ToString()) { FinancialYearsBLL FinancialYearBLL = (FinancialYearsBLL)result.Entity; throw new CustomException(Resources.Globalization.ValidationOverTimeDatesMustBeInSameFinancialYearText + "NewLine" + Resources.Globalization.FinancialYearInfoText + FinancialYearBLL.FinancialYear + ": NewLine" + Resources.Globalization.FinancialYearStartDateText + FinancialYearBLL.FinancialYearStartDate.Date.ToString(System.Configuration.ConfigurationManager.AppSettings["DateFormat"]) + "NewLine" + Resources.Globalization.FinancialYearEndDateText + FinancialYearBLL.FinancialYearEndDate.Date.ToString(System.Configuration.ConfigurationManager.AppSettings["DateFormat"])); } else if (result.EnumMember == OverTimeValidationEnum.RejectedBecauseAlreadyExist.ToString()) { throw new CustomException(Resources.Globalization.ValidationEmployeeAlreadyExistText); } Classes.Helpers.CommonHelper.ConflictValidationMessage(result); return(new HttpResponseMessage(HttpStatusCode.OK)); }
public JsonResult GetAllOverTimes() { var data = new OverTimesBLL().GetOverTimes() .Select(x => new { OverTimeID = x.OverTimeID, OverTimeStartDate = Globals.Calendar.GetUmAlQuraDate(x.OverTimeStartDate), OverTimeEndDate = Globals.Calendar.GetUmAlQuraDate(x.OverTimeEndDate), OverTimePeriod = x.OverTimePeriod, Tasks = x.Tasks }); return(Json(new { data = data }, JsonRequestBehavior.AllowGet)); }
public JsonResult GetEmployeesOverTimesAsRanksCategories(DateTime FromDate, DateTime ToDate, int OrganizationID) { IQueryable <EmployeesOverTimesBasedOnAssigngingsDTO> OverTimes; OverTimes = new OverTimesBLL().GetEmployeesOverTimesBasedOnAssigningsAsRanksCategories(FromDate, ToDate, OrganizationID); Session["EmployeesOverTimesDetails"] = OverTimes; var OverTimesByRanksCategories = OverTimes .GroupBy(x => x.RankCategoryName) .Select(y => new { KeyName = y.Key, Value = y.Count() }); return(Json(new { data = OverTimesByRanksCategories }, JsonRequestBehavior.AllowGet)); }
private OverTimesViewModel GetByOverTimeID(int id) { OverTimesBLL OverTimeBLL = new OverTimesBLL().GetByOverTimeID(id); OverTimesViewModel OverTimeVM = new OverTimesViewModel(); if (OverTimeBLL != null) { OverTimeVM.OverTimeID = OverTimeBLL.OverTimeID; OverTimeVM.OverTimeStartDate = OverTimeBLL.OverTimeStartDate.Date; OverTimeVM.OverTimeEndDate = OverTimeBLL.OverTimeEndDate; OverTimeVM.Tasks = OverTimeBLL.Tasks; OverTimeVM.WeekWorkHoursAvg = OverTimeBLL.WeekWorkHoursAvg; OverTimeVM.FridayHoursAvg = OverTimeBLL.FridayHoursAvg; OverTimeVM.SaturdayHoursAvg = OverTimeBLL.SaturdayHoursAvg; OverTimeVM.OverTimePeriod = OverTimeBLL.OverTimePeriod; OverTimeVM.Requester = OverTimeBLL.Requester; OverTimeVM.CreatedDate = OverTimeBLL.CreatedDate; OverTimeVM.CreatedBy = OverTimeVM.GetCreatedByDisplayed(OverTimeBLL.CreatedBy); } return(OverTimeVM); }