public OtherExpenseDetail VHasEmployee(OtherExpenseDetail otherExpenseDetail, IEmployeeService _employeeService)
        {
            Employee employee = _employeeService.GetObjectById(otherExpenseDetail.EmployeeId);

            if (employee == null)
            {
                otherExpenseDetail.Errors.Add("Employee", "Tidak ada");
            }
            return(otherExpenseDetail);
        }
        public OtherExpenseDetail VHasOtherExpense(OtherExpenseDetail otherExpenseDetail, IOtherExpenseService _otherExpenseService)
        {
            OtherExpense otherExpense = _otherExpenseService.GetObjectById(otherExpenseDetail.OtherExpenseId);

            if (otherExpense == null)
            {
                otherExpenseDetail.Errors.Add("OtherExpense", "Tidak ada");
            }
            return(otherExpenseDetail);
        }
        public string PrintError(OtherExpenseDetail 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. 4
0
        public dynamic UpdateDetail(OtherExpenseDetail model)
        {
            try
            {
                if (!AuthenticationModel.IsAllowed("Edit", Core.Constants.Constant.MenuName.OtherExpense, 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 = _otherExpenseDetailService.GetObjectById(model.Id);
                data.EmployeeId     = model.EmployeeId;
                data.Amount         = model.Amount;
                data.Remark         = model.Remark;
                data.Recurring      = model.Recurring;
                data.EffectiveDate  = model.EffectiveDate;
                data.OtherExpenseId = model.OtherExpenseId;
                model = _otherExpenseDetailService.UpdateObject(data, _otherExpenseService, _employeeService);
            }
            catch (Exception ex)
            {
                LOG.Error("Update 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 bool ValidDeleteObject(OtherExpenseDetail otherExpenseDetail)
 {
     otherExpenseDetail.Errors.Clear();
     return(isValid(otherExpenseDetail));
 }
 public bool ValidUpdateObject(OtherExpenseDetail otherExpenseDetail, IOtherExpenseService _otherExpenseService, IEmployeeService _employeeService)
 {
     otherExpenseDetail.Errors.Clear();
     ValidCreateObject(otherExpenseDetail, _otherExpenseService, _employeeService);
     return(isValid(otherExpenseDetail));
 }
        public bool isValid(OtherExpenseDetail obj)
        {
            bool isValid = !obj.Errors.Any();

            return(isValid);
        }
 public OtherExpenseDetail SoftDeleteObject(OtherExpenseDetail otherExpenseDetail)
 {
     return(otherExpenseDetail = _validator.ValidDeleteObject(otherExpenseDetail) ?
                                 _repository.SoftDeleteObject(otherExpenseDetail) : otherExpenseDetail);
 }
 public OtherExpenseDetail UpdateObject(OtherExpenseDetail otherExpenseDetail, IOtherExpenseService _otherExpenseService, IEmployeeService _employeeService)
 {
     return(otherExpenseDetail = _validator.ValidUpdateObject(otherExpenseDetail, _otherExpenseService, _employeeService) ? _repository.UpdateObject(otherExpenseDetail) : otherExpenseDetail);
 }
 public OtherExpenseDetail CreateObject(OtherExpenseDetail otherExpenseDetail, IOtherExpenseService _otherExpenseService, IEmployeeService _employeeService)
 {
     otherExpenseDetail.Errors = new Dictionary <String, String>();
     return(_validator.ValidCreateObject(otherExpenseDetail, _otherExpenseService, _employeeService) ? _repository.CreateObject(otherExpenseDetail) : otherExpenseDetail);
 }