public ActionResult Create(PreferencesCM m)
        {
            var entity = iPreferencesService.Get(m.ID) ?? new Preferences();

            try
            {
                if (ModelState.IsValid)
                {
                    if (m.ID == 0 && iPreferencesService.Exists(t => t.MerchantID == m.MerchantID))
                    {
                        throw new Exception("该商户参数已配置");
                    }

                    entity.MerchantID = m.MerchantID;

                    entity.APPID          = m.APPID.Trim();
                    entity.POSBaoMerchant = m.POSBaoMerchant.Trim();
                    entity.POSBaoKey      = m.POSBaoKey;


                    iPreferencesService.Save(entity);

                    iPreferencesService.Commit();

                    this.ShowTip();
                }
                else
                {
                    AddError();
                }
            }
            catch (Exception ex)
            {
                this.AddError(ErrorCode.Exception, ex.Message);
            }

            return(RedirectToAction("Create", new { ID = entity.ID }));
        }