public bool ValidCreateObject(PensionCompensation pensionCompensation, IEmployeeService _employeeService) { VHasEmployee(pensionCompensation, _employeeService); if (!isValid(pensionCompensation)) { return(false); } VHasPensionDate(pensionCompensation); if (!isValid(pensionCompensation)) { return(false); } VIsValidPensionValue(pensionCompensation); if (!isValid(pensionCompensation)) { return(false); } VIsValidPensionMultiply(pensionCompensation); if (!isValid(pensionCompensation)) { return(false); } VIsValidMedAndHousing(pensionCompensation); return(isValid(pensionCompensation)); }
public PensionCompensation VIsValidMedAndHousing(PensionCompensation pensionCompensation) { if (pensionCompensation.MedAndHousing < 0) { pensionCompensation.Errors.Add("MedAndHousing", "Harus lebih besar atau sama dengan 0"); } return(pensionCompensation); }
public PensionCompensation VIsValidPensionMultiply(PensionCompensation pensionCompensation) { if (pensionCompensation.PensionMultiply < 0) { pensionCompensation.Errors.Add("PensionMultiply", "Harus lebih besar atau sama dengan 0"); } return(pensionCompensation); }
public PensionCompensation VHasPensionDate(PensionCompensation pensionCompensation) { if (pensionCompensation.PensionDate == null || pensionCompensation.PensionDate.Equals(DateTime.FromBinary(0))) { pensionCompensation.Errors.Add("PensionDate", "Tidak valid"); } return(pensionCompensation); }
public PensionCompensation VHasEmployee(PensionCompensation pensionCompensation, IEmployeeService _employeeService) { Employee employee = _employeeService.GetObjectById(pensionCompensation.EmployeeId); if (employee == null) { pensionCompensation.Errors.Add("Employee", "Tidak ada"); } return(pensionCompensation); }
public string PrintError(PensionCompensation 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 PensionCompensation SoftDeleteObject(PensionCompensation pensionCompensation) { return(pensionCompensation = _validator.ValidDeleteObject(pensionCompensation) ? _repository.SoftDeleteObject(pensionCompensation) : pensionCompensation); }
public PensionCompensation UpdateObject(PensionCompensation pensionCompensation, IEmployeeService _employeeService) { return(pensionCompensation = _validator.ValidUpdateObject(pensionCompensation, _employeeService) ? _repository.UpdateObject(pensionCompensation) : pensionCompensation); }
public PensionCompensation CreateObject(PensionCompensation pensionCompensation, IEmployeeService _employeeService) { pensionCompensation.Errors = new Dictionary <String, String>(); return(_validator.ValidCreateObject(pensionCompensation, _employeeService) ? _repository.CreateObject(pensionCompensation) : pensionCompensation); }
public bool isValid(PensionCompensation obj) { bool isValid = !obj.Errors.Any(); return(isValid); }
public bool ValidDeleteObject(PensionCompensation pensionCompensation) { pensionCompensation.Errors.Clear(); return(isValid(pensionCompensation)); }
public bool ValidUpdateObject(PensionCompensation pensionCompensation, IEmployeeService _employeeService) { pensionCompensation.Errors.Clear(); ValidCreateObject(pensionCompensation, _employeeService); return(isValid(pensionCompensation)); }