コード例 #1
0
        public HttpResponseMessage RemoveEmployeeFromOverTime(OverTimesViewModel OverTimeVM)
        {
            List <OverTimesDetailsBLL> OverTimeEmployeesList = GetOverTimeDetailsFromSession();

            OverTimeEmployeesList.RemoveAt(OverTimeEmployeesList.FindIndex(e => e.EmployeeCareerHistory.EmployeeCode.EmployeeCodeNo.Equals(OverTimeVM.OverTimeDetailRequest.EmployeeCareerHistory.EmployeeCode.EmployeeCodeNo)));
            return(new HttpResponseMessage(HttpStatusCode.OK));
        }
コード例 #2
0
        public ActionResult Create(OverTimesViewModel overTimeVM)
        {
            //--== OverTime Master DataBind ===
            OverTimesBLL overTime = new OverTimesBLL();

            overTime.OverTimeEndDate   = (DateTime)overTimeVM.OverTimeEndDate;
            overTime.OverTimeStartDate = overTimeVM.OverTimeStartDate;
            overTime.Tasks             = overTimeVM.Tasks;
            overTime.FridayHoursAvg    = overTimeVM.FridayHoursAvg != null ? (double)overTimeVM.FridayHoursAvg : Convert.ToDouble(null);
            overTime.SaturdayHoursAvg  = overTimeVM.SaturdayHoursAvg != null ? (double)overTimeVM.SaturdayHoursAvg : Convert.ToDouble(null);
            overTime.WeekWorkHoursAvg  = overTimeVM.WeekWorkHoursAvg;
            overTime.Requester         = overTimeVM.Requester;
            overTime.LoginIdentity     = UserIdentity;
            //--== OverTime Details DataBind ==
            overTime.OverTimesDetails = GetOverTimeDetailsFromSession();
            //--== OverTime Days DataBind ==
            overTime.OverTimesDays = GetOverTimeDays(overTimeVM.OverTimesDays);
            Result result = overTime.Add();

            Session["OverTimeID"]         = overTime.OverTimeID;
            Session["OverTimesEmployees"] = null;
            if (result.EnumMember == OverTimeValidationEnum.RejectedBecauseEmployeeRequired.ToString())
            {
                throw new CustomException(Resources.Globalization.ValidationEmployeeRequiredText);
            }
            ResetEmployeeFromSession();
            //return View("Index");
            return(Json(new { OverTimeID = overTime.OverTimeID }, JsonRequestBehavior.AllowGet));
        }
コード例 #3
0
        public ActionResult EditOverTime(OverTimesViewModel OverTimeVM)
        {
            OverTimesBLL OverTime = new OverTimesBLL();

            OverTime.OverTimeID        = OverTimeVM.OverTimeID;
            OverTime.OverTimeStartDate = OverTimeVM.OverTimeStartDate;
            OverTime.OverTimeEndDate   = (DateTime)OverTimeVM.OverTimeEndDate;
            OverTime.Tasks             = OverTimeVM.Tasks;
            OverTime.FridayHoursAvg    = OverTimeVM.FridayHoursAvg != null ? (double)OverTimeVM.FridayHoursAvg : Convert.ToDouble(null);
            OverTime.SaturdayHoursAvg  = OverTimeVM.SaturdayHoursAvg != null ? (double)OverTimeVM.SaturdayHoursAvg : Convert.ToDouble(null);
            OverTime.WeekWorkHoursAvg  = OverTimeVM.WeekWorkHoursAvg;
            OverTime.Requester         = OverTimeVM.Requester;
            OverTime.LoginIdentity     = UserIdentity;
            Result result = OverTime.Update();

            OverTimesBLL OverTimeEntity = (OverTimesBLL)result.Entity;

            if (result.EnumMember == OverTimeValidationEnum.Done.ToString())
            {
                Session["OverTimeID"] = ((OverTimesBLL)result.Entity).OverTimeID;
                ClearOverTimeDetailsFromSession();
            }
            else if (result.EnumMember == OverTimeValidationEnum.RejectedBecauseOfEmployeeStatus.ToString())
            {
                throw new CustomException(Resources.Globalization.ValidationEmployeeRequiredText);
            }


            return(View(OverTimeVM));
        }
コード例 #4
0
        public ActionResult OverTimeApproval(OverTimesViewModel OverTimeVM, string BtnType)
        {
            Result      result  = null;
            ExpensesBLL expense = new OverTimesBLL();

            expense.ApprovedBy = UserIdentity.EmployeeCodeID;
            if (BtnType == "Approve")
            {
                result = expense.Approve(OverTimeVM.OverTimeID);
            }
            else
            {
                result = expense.ApproveCancel(OverTimeVM.OverTimeID);
            }

            if (result.EnumMember == OverTimeValidationEnum.RejectedBecauseOfAlreadyApprove.ToString())
            {
                throw new CustomException(Resources.Globalization.ValidationOverTimeAlreadyApproveText);
            }

            if (result.EnumMember == OverTimeValidationEnum.RejectedBecauseOfAlreadyApproveCancel.ToString())
            {
                throw new CustomException(Resources.Globalization.ValidationOverTimeAlreadyApproveCancelText);
            }

            return(View());
        }
コード例 #5
0
        public ActionResult Delete(OverTimesViewModel OverTimeVM)
        {
            OverTimesBLL overTimeBll = new OverTimesBLL();

            overTimeBll.OverTimeID    = OverTimeVM.OverTimeID;
            overTimeBll.LoginIdentity = UserIdentity;
            overTimeBll.Remove();
            return(RedirectToAction("Index"));
        }
コード例 #6
0
        public JsonResult GetOverTimeByOverTimeID(int OverTimeID)
        {
            OverTimesViewModel vm = this.GetByOverTimeID(OverTimeID);

            if (vm == null)
            {
                vm = new OverTimesViewModel();
            }
            return(Json(vm, JsonRequestBehavior.AllowGet));
        }
コード例 #7
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));
        }
コード例 #8
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));
        }
コード例 #9
0
        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);
        }