private Result ApproveOverTime(OverTimesBLL OverTimeBll, bool IsApprove) { try { Result result = new Result(); //OverTimes overTime = new OverTimesDAL().GetByOverTimeID(OverTimeBll.OverTimeID); // if (OverTimeBll.IsApproved && IsApprove) { result.Entity = OverTimeBll; result.EnumType = typeof(OverTimeValidationEnum); result.EnumMember = OverTimeValidationEnum.RejectedBecauseOfAlreadyApprove.ToString(); return(result); } // if (!OverTimeBll.IsApproved && !IsApprove) { result.Entity = this; result.EnumType = typeof(OverTimeValidationEnum); result.EnumMember = OverTimeValidationEnum.RejectedBecauseOfAlreadyApproveCancel.ToString(); return(result); } OverTimes overTime = new OverTimes(); overTime.IsApproved = IsApprove; overTime.OverTimeID = OverTimeBll.OverTimeID; overTime.OverTimeStartDate = OverTimeBll.OverTimeStartDate; if (IsApprove) { overTime.ApprovedBy = OverTimeBll.ApprovedBy; overTime.ApprovedDate = DateTime.Now; overTime.LastUpdatedBy = OverTimeBll.ApprovedBy; OverTimeBll.OverTimesDetails = new OverTimesDetailsBLL().GetOverTimeDetailsByOverTimeID(OverTimeBll.OverTimeID); //overTime.OverTimesDetails.Select(x => new OverTimesDetailsBLL().MapOverTimeDetail(x)).ToList();// new DelegationsDetailsBLL().MapDelegationDetail(Delegation.DelegationsDetails); } else { OverTimeBll.OverTimesDetails = new OverTimesDetailsBLL().GetOverTimeDetailsByOverTimeID(OverTimeBll.OverTimeID);// new DelegationsDetailsBLL().MapDelegationDetail(Delegation.DelegationsDetails); overTime.LastUpdatedBy = OverTimeBll.ApprovedBy; overTime.ApprovedBy = null; overTime.ApprovedDate = null; } new OverTimesDAL().Approve(overTime); //send SMS message. SendSMS(OverTimeBll); if (OverTimeBll.OverTimeID != 0) { result.Entity = this; result.EnumType = typeof(OverTimeValidationEnum); result.EnumMember = OverTimeValidationEnum.Done.ToString(); } return(result); } catch { throw; } }
public Result Add() { Result result; // validate employees PassengerOrder limit if (this.OverTimesDetails == null || this.OverTimesDetails.Count <= 0) { result = new Result(); result.Entity = null; result.EnumType = typeof(OverTimeValidationEnum); result.EnumMember = OverTimeValidationEnum.RejectedBecauseEmployeeRequired.ToString(); return(result); } OverTimes overTime = new OverTimes(); overTime.CreatedDate = DateTime.Now; overTime.CreatedBy = this.LoginIdentity.EmployeeCodeID; overTime.OverTimeEndDate = this.OverTimeEndDate; overTime.OverTimeStartDate = this.OverTimeStartDate; overTime.Tasks = this.Tasks; overTime.FridayHoursAvg = this.FridayHoursAvg; overTime.SaturdayHoursAvg = this.SaturdayHoursAvg; overTime.WeekWorkHoursAvg = this.WeekWorkHoursAvg; overTime.Requester = this.Requester; this.OverTimesDetails.ForEach(c => overTime.OverTimesDetails.Add(new OverTimesDetails() { CreatedBy = this.LoginIdentity.EmployeeCodeID, CreateDate = DateTime.Now, EmployeeCareerHistoryID = c.EmployeeCareerHistory.EmployeeCareerHistoryID })); this.OverTimesDays.ForEach(c => overTime.OverTimesDays.Add(new OverTimesDays() { OverTimeDay = c.OverTimeDay })); this.OverTimeID = new OverTimesDAL().Insert(overTime); result = new Result(); result.Entity = this; result.EnumMember = OverTimeValidationEnum.Done.ToString(); result.EnumType = typeof(OverTimeValidationEnum); return(result); }
public Result Update() { Result result = null; List <OverTimesDetailsBLL> OverTimeDetailBLLList = new OverTimesDetailsBLL().GetOverTimeDetailsByOverTimeID(this.OverTimeID); // validate employees if (OverTimeDetailBLLList == null || OverTimeDetailBLLList.Count <= 0) { result = new Result(); result.Entity = null; result.EnumType = typeof(OverTimeValidationEnum); result.EnumMember = OverTimeValidationEnum.RejectedBecauseEmployeeRequired.ToString(); return(result); } else { OverTimes overTime = new OverTimes() { OverTimeID = this.OverTimeID, Tasks = this.Tasks, WeekWorkHoursAvg = this.WeekWorkHoursAvg, FridayHoursAvg = this.FridayHoursAvg, SaturdayHoursAvg = this.SaturdayHoursAvg, Requester = this.Requester, LastUpdatedDate = DateTime.Now, LastUpdatedBy = this.LoginIdentity.EmployeeCodeID }; new OverTimesDAL().Update(overTime); result = new Result() { Entity = this, EnumType = typeof(OverTimeValidationEnum), EnumMember = OverTimeValidationEnum.Done.ToString() }; } return(result); }
internal OverTimesBLL MapOverTime(OverTimes OverTime) { try { OverTimesBLL OverTimeBLL = null; if (OverTime != null) { OverTimeBLL = new OverTimesBLL() { OverTimeID = OverTime.OverTimeID, OverTimeStartDate = OverTime.OverTimeStartDate, OverTimeEndDate = OverTime.OverTimeEndDate, Tasks = OverTime.Tasks, WeekWorkHoursAvg = OverTime.WeekWorkHoursAvg, FridayHoursAvg = OverTime.FridayHoursAvg.HasValue ? OverTime.FridayHoursAvg.Value : 0, SaturdayHoursAvg = OverTime.SaturdayHoursAvg.HasValue ? OverTime.SaturdayHoursAvg.Value : 0, Requester = OverTime.Requester, CreatedBy = new EmployeesCodesBLL().MapEmployeeCode(OverTime.CreatedByNav), CreatedDate = OverTime.CreatedDate, IsApproved = OverTime.IsApproved, ApprovedBy = OverTime.ApprovedBy, ApprovedDate = OverTime.ApprovedDate }; OverTimeBLL.OverTimesDays = new List <OverTimesDaysBLL>(); OverTime.OverTimesDays.ToList().ForEach(c => OverTimeBLL.OverTimesDays.Add(new OverTimesDaysBLL() { OverTimeDay = c.OverTimeDay, OverTimeDayID = c.OverTimeDayID })); } return(OverTimeBLL); } catch { throw; } }