public dynamic GetInfoDetail(int Id) { SalaryEmployeeDetail model = new SalaryEmployeeDetail(); try { model = _salaryEmployeeDetailService.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.SalaryEmployeeId, model.SalaryItemId, SalaryItemCode = model.SalaryItem.Code, SalaryItemName = model.SalaryItem.Name, model.Amount, model.Errors }, JsonRequestBehavior.AllowGet)); }
public dynamic DeleteDetail(SalaryEmployeeDetail model) { try { if (!AuthenticationModel.IsAllowed("Edit", Core.Constants.Constant.MenuName.EmployeeSalary, 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 = _salaryEmployeeDetailService.GetObjectById(model.Id); model = _salaryEmployeeDetailService.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 SalaryEmployeeDetail VHasAmount(SalaryEmployeeDetail salaryEmployeeDetail) { if (salaryEmployeeDetail.Amount < 0) { salaryEmployeeDetail.Errors.Add("Amount", "Harus lebih besar atau sama dengan 0"); } return(salaryEmployeeDetail); }
public SalaryEmployeeDetail VHasSalaryItem(SalaryEmployeeDetail salaryEmployeeDetail, ISalaryItemService _salaryItemService) { SalaryItem salaryItem = _salaryItemService.GetObjectById(salaryEmployeeDetail.SalaryItemId); if (salaryItem == null) { salaryEmployeeDetail.Errors.Add("SalaryItem", "Tidak ada"); } return(salaryEmployeeDetail); }
public string PrintError(SalaryEmployeeDetail 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 bool ValidCreateObject(SalaryEmployeeDetail salaryEmployeeDetail, ISalaryEmployeeService _salaryEmployeeService, ISalaryItemService _salaryItemService) { VHasSalaryEmployee(salaryEmployeeDetail, _salaryEmployeeService); if (!isValid(salaryEmployeeDetail)) { return(false); } VHasSalaryItem(salaryEmployeeDetail, _salaryItemService); if (!isValid(salaryEmployeeDetail)) { return(false); } VHasAmount(salaryEmployeeDetail); return(isValid(salaryEmployeeDetail)); }
public SalaryEmployee CreateObject(SalaryEmployee salaryEmployee, IEmployeeService _employeeService, ISalaryEmployeeDetailService _salaryEmployeeDetailService, ISalaryItemService _salaryItemService, ISalaryStandardDetailService _salaryStandardDetailService) { salaryEmployee.Errors = new Dictionary <String, String>(); if (_validator.ValidCreateObject(salaryEmployee, _employeeService, this)) { SalaryEmployee activesalaryEmployee = GetActiveObject(); // Activate yg baru if (activesalaryEmployee == null || (salaryEmployee.EffectiveDate > activesalaryEmployee.EffectiveDate && salaryEmployee.EffectiveDate <= DateTime.Now)) { salaryEmployee.IsActive = true; } _repository.CreateObject(salaryEmployee); // Deactivate yg lama if (activesalaryEmployee != null && salaryEmployee.IsActive) { activesalaryEmployee.IsActive = false; _repository.UpdateObject(activesalaryEmployee); } if (!salaryEmployee.Errors.Any()) { Employee employee = _employeeService.GetObjectById(salaryEmployee.EmployeeId); IList <SalaryStandardDetail> details = _salaryStandardDetailService.GetObjectsByTitleInfoId(employee.TitleInfoId); foreach (var detail in details) { SalaryEmployeeDetail sed = new SalaryEmployeeDetail { SalaryEmployeeId = salaryEmployee.Id, SalaryItemId = detail.SalaryItemId, Amount = detail.Amount, }; _salaryEmployeeDetailService.CreateObject(sed, this, _salaryItemService); } ; } } return(salaryEmployee); }
public bool isValid(SalaryEmployeeDetail obj) { bool isValid = !obj.Errors.Any(); return(isValid); }
public bool ValidDeleteObject(SalaryEmployeeDetail salaryEmployeeDetail) { salaryEmployeeDetail.Errors.Clear(); return(isValid(salaryEmployeeDetail)); }
public bool ValidUpdateObject(SalaryEmployeeDetail salaryEmployeeDetail, ISalaryEmployeeService _salaryEmployeeService, ISalaryItemService _salaryItemService) { salaryEmployeeDetail.Errors.Clear(); ValidCreateObject(salaryEmployeeDetail, _salaryEmployeeService, _salaryItemService); return(isValid(salaryEmployeeDetail)); }
public SalaryEmployeeDetail SoftDeleteObject(SalaryEmployeeDetail salaryEmployeeDetail) { return(salaryEmployeeDetail = _validator.ValidDeleteObject(salaryEmployeeDetail) ? _repository.SoftDeleteObject(salaryEmployeeDetail) : salaryEmployeeDetail); }
public SalaryEmployeeDetail UpdateObject(SalaryEmployeeDetail salaryEmployeeDetail, ISalaryEmployeeService _salaryEmployeeService, ISalaryItemService _salaryItemService) { return(salaryEmployeeDetail = _validator.ValidUpdateObject(salaryEmployeeDetail, _salaryEmployeeService, _salaryItemService) ? _repository.UpdateObject(salaryEmployeeDetail) : salaryEmployeeDetail); }
public SalaryEmployeeDetail CreateObject(SalaryEmployeeDetail salaryEmployeeDetail, ISalaryEmployeeService _salaryEmployeeService, ISalaryItemService _salaryItemService) { salaryEmployeeDetail.Errors = new Dictionary <String, String>(); return(_validator.ValidCreateObject(salaryEmployeeDetail, _salaryEmployeeService, _salaryItemService) ? _repository.CreateObject(salaryEmployeeDetail) : salaryEmployeeDetail); }