public OtherIncomeDetail FixDate(OtherIncomeDetail otherIncomeDetail, IOtherIncomeService _otherIncomeService) { otherIncomeDetail.EndDate = otherIncomeDetail.EffectiveDate; OtherIncome otherIncome = _otherIncomeService.GetObjectById(otherIncomeDetail.OtherIncomeId); if (otherIncome != null) { DateTime curDay = otherIncomeDetail.EffectiveDate; int cnt = otherIncomeDetail.Recurring; while (cnt > 1) { switch ((Constant.SalaryItemStatus)otherIncome.SalaryStatus) { case Constant.SalaryItemStatus.Daily: otherIncomeDetail.EndDate = curDay.AddDays(1); break; case Constant.SalaryItemStatus.Weekly: otherIncomeDetail.EndDate = curDay.AddDays(7); break; case Constant.SalaryItemStatus.Monthly: otherIncomeDetail.EndDate = curDay.AddMonths(1); break; case Constant.SalaryItemStatus.Yearly: otherIncomeDetail.EndDate = curDay.AddYears(1); break; } curDay = otherIncomeDetail.EndDate; cnt--; } } return(otherIncomeDetail); }
public dynamic GetInfoDetail(int Id) { OtherIncomeDetail model = new OtherIncomeDetail(); try { model = _otherIncomeDetailService.GetObjectById(Id); } catch (Exception ex) { LOG.Error("GetInfo", ex); model.Errors = new Dictionary <string, string>(); model.Errors.Add("Generic", "Error " + ex); return(Json(new { model.Errors }, JsonRequestBehavior.AllowGet)); } return(Json(new { model.Id, model.OtherIncomeId, model.EmployeeId, EmployeeNIK = model.Employee.NIK, EmployeeName = model.Employee.Name, model.Amount, model.EffectiveDate, model.Recurring, model.Remark, model.Errors }, JsonRequestBehavior.AllowGet)); }
public bool ValidCreateObject(OtherIncomeDetail otherIncomeDetail, IOtherIncomeService _otherIncomeService, IEmployeeService _employeeService) { VHasOtherIncome(otherIncomeDetail, _otherIncomeService); if (!isValid(otherIncomeDetail)) { return(false); } VHasEmployee(otherIncomeDetail, _employeeService); if (!isValid(otherIncomeDetail)) { return(false); } VHasEffectiveDate(otherIncomeDetail); if (!isValid(otherIncomeDetail)) { return(false); } VHasAmount(otherIncomeDetail); if (!isValid(otherIncomeDetail)) { return(false); } VHasRecurring(otherIncomeDetail); FixDate(otherIncomeDetail, _otherIncomeService); return(isValid(otherIncomeDetail)); }
public dynamic InsertDetail(OtherIncomeDetail model) { try { if (!AuthenticationModel.IsAllowed("Edit", Core.Constants.Constant.MenuName.OtherIncome, Core.Constants.Constant.MenuGroupName.Utility)) { Dictionary <string, string> Errors = new Dictionary <string, string>(); Errors.Add("Generic", "You are Not Allowed to Edit record"); return(Json(new { Errors }, JsonRequestBehavior.AllowGet)); } model = _otherIncomeDetailService.CreateObject(model, _otherIncomeService, _employeeService); } catch (Exception ex) { LOG.Error("Insert Failed", ex); Dictionary <string, string> Errors = new Dictionary <string, string>(); Errors.Add("Generic", "Error " + ex); return(Json(new { Errors }, JsonRequestBehavior.AllowGet)); } return(Json(new { model.Errors, })); }
public dynamic DeleteDetail(OtherIncomeDetail model) { try { if (!AuthenticationModel.IsAllowed("Edit", Core.Constants.Constant.MenuName.OtherIncome, Core.Constants.Constant.MenuGroupName.Utility)) { Dictionary <string, string> Errors = new Dictionary <string, string>(); Errors.Add("Generic", "You are Not Allowed to Edit record"); return(Json(new { Errors }, JsonRequestBehavior.AllowGet)); } var data = _otherIncomeDetailService.GetObjectById(model.Id); model = _otherIncomeDetailService.SoftDeleteObject(data); } catch (Exception ex) { LOG.Error("Delete Failed", ex); Dictionary <string, string> Errors = new Dictionary <string, string>(); Errors.Add("Generic", "Error " + ex); return(Json(new { Errors }, JsonRequestBehavior.AllowGet)); } return(Json(new { model.Errors, })); }
public OtherIncomeDetail VHasRecurring(OtherIncomeDetail otherIncomeDetail) { if (otherIncomeDetail.Recurring < 1) { otherIncomeDetail.Errors.Add("Recurring", "Harus lebih besar atau sama dengan 1"); } return(otherIncomeDetail); }
public OtherIncomeDetail VHasAmount(OtherIncomeDetail otherIncomeDetail) { if (otherIncomeDetail.Amount < 0) { otherIncomeDetail.Errors.Add("Amount", "Harus lebih besar atau sama dengan 0"); } return(otherIncomeDetail); }
public OtherIncomeDetail VHasEffectiveDate(OtherIncomeDetail otherIncomeDetail) { if (otherIncomeDetail.EffectiveDate == null || otherIncomeDetail.EffectiveDate.Equals(DateTime.FromBinary(0))) { otherIncomeDetail.Errors.Add("EffectiveDate", "Tidak valid"); } return(otherIncomeDetail); }
public OtherIncomeDetail VHasEmployee(OtherIncomeDetail otherIncomeDetail, IEmployeeService _employeeService) { Employee employee = _employeeService.GetObjectById(otherIncomeDetail.EmployeeId); if (employee == null) { otherIncomeDetail.Errors.Add("Employee", "Tidak ada"); } return(otherIncomeDetail); }
public OtherIncomeDetail VHasOtherIncome(OtherIncomeDetail otherIncomeDetail, IOtherIncomeService _otherIncomeService) { OtherIncome otherIncome = _otherIncomeService.GetObjectById(otherIncomeDetail.OtherIncomeId); if (otherIncome == null) { otherIncomeDetail.Errors.Add("OtherIncome", "Tidak ada"); } return(otherIncomeDetail); }
public string PrintError(OtherIncomeDetail obj) { string erroroutput = ""; KeyValuePair <string, string> first = obj.Errors.ElementAt(0); erroroutput += first.Key + "," + first.Value; foreach (KeyValuePair <string, string> pair in obj.Errors.Skip(1)) { erroroutput += Environment.NewLine; erroroutput += pair.Key + "," + pair.Value; } return(erroroutput); }
public dynamic UpdateDetail(OtherIncomeDetail model) { try { if (!AuthenticationModel.IsAllowed("Edit", Core.Constants.Constant.MenuName.OtherIncome, Core.Constants.Constant.MenuGroupName.Utility)) { Dictionary <string, string> Errors = new Dictionary <string, string>(); Errors.Add("Generic", "You are Not Allowed to Edit record"); return(Json(new { Errors }, JsonRequestBehavior.AllowGet)); } var data = _otherIncomeDetailService.GetObjectById(model.Id); data.EmployeeId = model.EmployeeId; data.Amount = model.Amount; data.Remark = model.Remark; data.Recurring = model.Recurring; data.EffectiveDate = model.EffectiveDate; data.OtherIncomeId = model.OtherIncomeId; model = _otherIncomeDetailService.UpdateObject(data, _otherIncomeService, _employeeService); } catch (Exception ex) { LOG.Error("Update Failed", ex); Dictionary <string, string> Errors = new Dictionary <string, string>(); Errors.Add("Generic", "Error " + ex); return(Json(new { Errors }, JsonRequestBehavior.AllowGet)); } return(Json(new { model.Errors, })); }
public bool ValidDeleteObject(OtherIncomeDetail otherIncomeDetail) { otherIncomeDetail.Errors.Clear(); return(isValid(otherIncomeDetail)); }
public bool ValidUpdateObject(OtherIncomeDetail otherIncomeDetail, IOtherIncomeService _otherIncomeService, IEmployeeService _employeeService) { otherIncomeDetail.Errors.Clear(); ValidCreateObject(otherIncomeDetail, _otherIncomeService, _employeeService); return(isValid(otherIncomeDetail)); }
public bool isValid(OtherIncomeDetail obj) { bool isValid = !obj.Errors.Any(); return(isValid); }
public OtherIncomeDetail SoftDeleteObject(OtherIncomeDetail otherIncomeDetail) { return(otherIncomeDetail = _validator.ValidDeleteObject(otherIncomeDetail) ? _repository.SoftDeleteObject(otherIncomeDetail) : otherIncomeDetail); }
public OtherIncomeDetail UpdateObject(OtherIncomeDetail otherIncomeDetail, IOtherIncomeService _otherIncomeService, IEmployeeService _employeeService) { return(otherIncomeDetail = _validator.ValidUpdateObject(otherIncomeDetail, _otherIncomeService, _employeeService) ? _repository.UpdateObject(otherIncomeDetail) : otherIncomeDetail); }
public OtherIncomeDetail CreateObject(OtherIncomeDetail otherIncomeDetail, IOtherIncomeService _otherIncomeService, IEmployeeService _employeeService) { otherIncomeDetail.Errors = new Dictionary <String, String>(); return(_validator.ValidCreateObject(otherIncomeDetail, _otherIncomeService, _employeeService) ? _repository.CreateObject(otherIncomeDetail) : otherIncomeDetail); }