Esempio n. 1
0
        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));
        }
Esempio n. 2
0
        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,
            }));
        }
Esempio n. 3
0
 public SalaryEmployeeDetail VHasAmount(SalaryEmployeeDetail salaryEmployeeDetail)
 {
     if (salaryEmployeeDetail.Amount < 0)
     {
         salaryEmployeeDetail.Errors.Add("Amount", "Harus lebih besar atau sama dengan 0");
     }
     return(salaryEmployeeDetail);
 }
Esempio n. 4
0
        public SalaryEmployeeDetail VHasSalaryItem(SalaryEmployeeDetail salaryEmployeeDetail, ISalaryItemService _salaryItemService)
        {
            SalaryItem salaryItem = _salaryItemService.GetObjectById(salaryEmployeeDetail.SalaryItemId);

            if (salaryItem == null)
            {
                salaryEmployeeDetail.Errors.Add("SalaryItem", "Tidak ada");
            }
            return(salaryEmployeeDetail);
        }
Esempio n. 5
0
        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);
        }
Esempio n. 6
0
 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));
 }
Esempio n. 7
0
 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);
 }
Esempio n. 8
0
        public bool isValid(SalaryEmployeeDetail obj)
        {
            bool isValid = !obj.Errors.Any();

            return(isValid);
        }
Esempio n. 9
0
 public bool ValidDeleteObject(SalaryEmployeeDetail salaryEmployeeDetail)
 {
     salaryEmployeeDetail.Errors.Clear();
     return(isValid(salaryEmployeeDetail));
 }
Esempio n. 10
0
 public bool ValidUpdateObject(SalaryEmployeeDetail salaryEmployeeDetail, ISalaryEmployeeService _salaryEmployeeService, ISalaryItemService _salaryItemService)
 {
     salaryEmployeeDetail.Errors.Clear();
     ValidCreateObject(salaryEmployeeDetail, _salaryEmployeeService, _salaryItemService);
     return(isValid(salaryEmployeeDetail));
 }
Esempio n. 11
0
 public SalaryEmployeeDetail SoftDeleteObject(SalaryEmployeeDetail salaryEmployeeDetail)
 {
     return(salaryEmployeeDetail = _validator.ValidDeleteObject(salaryEmployeeDetail) ?
                                   _repository.SoftDeleteObject(salaryEmployeeDetail) : salaryEmployeeDetail);
 }
Esempio n. 12
0
 public SalaryEmployeeDetail UpdateObject(SalaryEmployeeDetail salaryEmployeeDetail, ISalaryEmployeeService _salaryEmployeeService, ISalaryItemService _salaryItemService)
 {
     return(salaryEmployeeDetail = _validator.ValidUpdateObject(salaryEmployeeDetail, _salaryEmployeeService, _salaryItemService) ? _repository.UpdateObject(salaryEmployeeDetail) : salaryEmployeeDetail);
 }
Esempio n. 13
0
 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);
 }