Пример #1
0
        public HttpResponseMessage RemoveEmployeeFromDB(int id)
        {
            OverTimesDetailsBLL overTimeDetailBLL = new OverTimesDetailsBLL();

            overTimeDetailBLL.LoginIdentity = UserIdentity;
            overTimeDetailBLL.Remove(id);
            return(new HttpResponseMessage(HttpStatusCode.OK));
        }
Пример #2
0
        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));
        }
Пример #3
0
        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));
        }