public dynamic DeleteDetail(THRDetail model) { try { if (!AuthenticationModel.IsAllowed("Edit", Core.Constants.Constant.MenuName.THR, 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 = _thrDetailService.GetObjectById(model.Id); model = _thrDetailService.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 dynamic GetInfoDetail(int Id) { THRDetail model = new THRDetail(); try { model = _thrDetailService.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.THRId, model.EmployeeId, EmployeeNIK = model.Employee.NIK, EmployeeName = model.Employee.Name, EmployeeReligion = model.Employee.Religion, model.Errors }, JsonRequestBehavior.AllowGet)); }
public dynamic InsertDetail(THRDetail model) { try { if (!AuthenticationModel.IsAllowed("Edit", Core.Constants.Constant.MenuName.THR, 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 = _thrDetailService.CreateObject(model, _thrService, _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 THRDetail VHasTHR(THRDetail thrDetail, ITHRService _thrService) { THR thr = _thrService.GetObjectById(thrDetail.THRId); if (thr == null) { thrDetail.Errors.Add("THR", "Tidak ada"); } return(thrDetail); }
//public THRDetail VHasAmount(THRDetail thrDetail) //{ // if (thrDetail.Amount < 0) // { // thrDetail.Errors.Add("Amount", "Harus lebih besar atau sama dengan 0"); // } // return thrDetail; //} public bool ValidCreateObject(THRDetail thrDetail, ITHRService _thrService, IEmployeeService _employeeService, ITHRDetailService _thrDetailService) { VHasTHR(thrDetail, _thrService); if (!isValid(thrDetail)) { return(false); } VHasEmployee(thrDetail, _employeeService, _thrDetailService); //if (!isValid(thrDetail)) { return false; } //VHasAmount(thrDetail); return(isValid(thrDetail)); }
public string PrintError(THRDetail 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 THRDetail VHasEmployee(THRDetail thrDetail, IEmployeeService _employeeService, ITHRDetailService _thrDetailService) { Employee employee = _employeeService.GetObjectById(thrDetail.EmployeeId); if (employee == null) { thrDetail.Errors.Add("Employee", "Tidak ada"); } else { THRDetail thrDetail2 = _thrDetailService.GetObjectByEmployeeIdAndTHRId(thrDetail.EmployeeId, thrDetail.THRId); if (thrDetail2 != null) { thrDetail.Errors.Add("Employee", "Sudah ada"); } } return(thrDetail); }
public dynamic InsertManyDetails(int id, List <int> selIDs) { Dictionary <string, string> Errors = new Dictionary <string, string>(); try { if (!AuthenticationModel.IsAllowed("Edit", Core.Constants.Constant.MenuName.THR, Core.Constants.Constant.MenuGroupName.Utility)) { Errors.Add("Generic", "You are Not Allowed to Edit record"); return(Json(new { Errors }, JsonRequestBehavior.AllowGet)); } THRDetail model = null; foreach (var eid in selIDs) { model = new THRDetail { EmployeeId = eid, THRId = id, }; model = _thrDetailService.CreateObject(model, _thrService, _employeeService); } } catch (Exception ex) { LOG.Error("Insert Failed", ex); Errors.Add("Generic", "Error " + ex); return(Json(new { Errors }, JsonRequestBehavior.AllowGet)); } return(Json(new { Errors, })); }
public THRDetail SoftDeleteObject(THRDetail thrDetail) { return(thrDetail = _validator.ValidDeleteObject(thrDetail) ? _repository.SoftDeleteObject(thrDetail) : thrDetail); }
public THRDetail UpdateObject(THRDetail thrDetail, ITHRService _thrService, IEmployeeService _employeeService) { return(thrDetail = _validator.ValidUpdateObject(thrDetail, _thrService, _employeeService, this) ? _repository.UpdateObject(thrDetail) : thrDetail); }
public THRDetail CreateObject(THRDetail thrDetail, ITHRService _thrService, IEmployeeService _employeeService) { thrDetail.Errors = new Dictionary <String, String>(); return(_validator.ValidCreateObject(thrDetail, _thrService, _employeeService, this) ? _repository.CreateObject(thrDetail) : thrDetail); }
public bool isValid(THRDetail obj) { bool isValid = !obj.Errors.Any(); return(isValid); }
public bool ValidDeleteObject(THRDetail thrDetail) { thrDetail.Errors.Clear(); return(isValid(thrDetail)); }
public bool ValidUpdateObject(THRDetail thrDetail, ITHRService _thrService, IEmployeeService _employeeService, ITHRDetailService _thrDetailService) { thrDetail.Errors.Clear(); ValidCreateObject(thrDetail, _thrService, _employeeService, _thrDetailService); return(isValid(thrDetail)); }