Пример #1
0
        public dynamic InsertDetail(SalaryStandardDetail model)
        {
            try
            {
                if (!AuthenticationModel.IsAllowed("Edit", Core.Constants.Constant.MenuName.SalaryStandard, 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 = _salaryStandardDetailService.CreateObject(model, _salaryStandardService, _salaryItemService);
            }
            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,
            }));
        }
Пример #2
0
 public SalaryStandard CreateObject(SalaryStandard salaryStandard, ITitleInfoService _titleInfoService,
                                    ISalaryStandardDetailService _salaryStandardDetailService, ISalaryItemService _salaryItemService)
 {
     salaryStandard.Errors = new Dictionary <String, String>();
     if (_validator.ValidCreateObject(salaryStandard, _titleInfoService))
     {
         _repository.CreateObject(salaryStandard);
         if (!salaryStandard.Errors.Any())
         {
             foreach (var x in Enum.GetNames(typeof(Core.Constants.Constant.LegacySalaryItem)))
             {
                 SalaryStandardDetail ssd = new SalaryStandardDetail
                 {
                     SalaryStandardId = salaryStandard.Id,
                     SalaryItemId     = _salaryItemService.GetObjectByCode(x).Id,
                 };
                 _salaryStandardDetailService.CreateObject(ssd, this, _salaryItemService);
             }
         }
     }
     return(salaryStandard);
 }