public SlipGajiMini VHasMonth(SlipGajiMini slipGajiMini) { if (slipGajiMini.MONTHyear.Equals(DateTime.FromBinary(0))) { slipGajiMini.Errors.Add("Month", "Tidak valid"); } return(slipGajiMini); }
public bool ValidCreateObject(SlipGajiMini slipGajiMini, IEmployeeService _employeeService) { VHasEmployee(slipGajiMini, _employeeService); if (!isValid(slipGajiMini)) { return(false); } VHasMonth(slipGajiMini); return(isValid(slipGajiMini)); }
public SlipGajiMini VHasEmployee(SlipGajiMini slipGajiMini, IEmployeeService _employeeService) { Employee employee = _employeeService.GetObjectById(slipGajiMini.EmployeeId); if (employee == null) { slipGajiMini.Errors.Add("Employee", "Tidak valid"); } return(slipGajiMini); }
public SlipGajiMini GetOrNewObjectByEmployeeMonth(int EmployeeId, DateTime YearMonth) { SlipGajiMini slipGajiMini = _repository.FindAll(x => x.EmployeeId == EmployeeId && x.MONTHyear.Year == YearMonth.Year && x.MONTHyear.Month == YearMonth.Month).FirstOrDefault(); if (slipGajiMini == null) { slipGajiMini = new SlipGajiMini(); slipGajiMini.Errors = new Dictionary <string, string>(); } return(slipGajiMini); }
public string PrintError(SlipGajiMini 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 SlipGajiMini CreateOrUpdateObject(SlipGajiMini slipGajiMini, IEmployeeService _employeeService) { slipGajiMini.Errors = new Dictionary <String, String>(); if (_validator.ValidCreateObject(slipGajiMini, _employeeService)) { //SlipGajiMini slipGajiMini2 = GetObjectByEmployeeMonth(slipGajiMini.EmployeeId, slipGajiMini.MONTH); if (slipGajiMini.Id > 0) { _repository.UpdateObject(slipGajiMini); } else { _repository.CreateObject(slipGajiMini); } } return(slipGajiMini); }
public bool isValid(SlipGajiMini obj) { bool isValid = !obj.Errors.Any(); return(isValid); }
public bool ValidDeleteObject(SlipGajiMini slipGajiMini) { slipGajiMini.Errors.Clear(); return(isValid(slipGajiMini)); }
public bool ValidUpdateObject(SlipGajiMini slipGajiMini, IEmployeeService _employeeService) { slipGajiMini.Errors.Clear(); ValidCreateObject(slipGajiMini, _employeeService); return(isValid(slipGajiMini)); }
public SlipGajiMini UpdateObject(SlipGajiMini slipGajiMini, IEmployeeService _employeeService) { return(slipGajiMini = _validator.ValidUpdateObject(slipGajiMini, _employeeService) ? _repository.UpdateObject(slipGajiMini) : slipGajiMini); }
public SlipGajiMini CreateObject(SlipGajiMini slipGajiMini, IEmployeeService _employeeService) { slipGajiMini.Errors = new Dictionary <String, String>(); return(_validator.ValidCreateObject(slipGajiMini, _employeeService) ? _repository.CreateObject(slipGajiMini) : slipGajiMini); }