/// <summary>
        /// 保存或更新收单渠道信息
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public OpResult SaveOrUpdate(PayChannelManage model)
        {
            var source    = model;
            var existsObj = PCManageRepost.GetQuery(o => o.Id != model.Id && o.ChannelCode == model.ChannelCode).FirstOrDefault();

            if (existsObj != null)
            {
                return(OpResult.Fail(message: "收单渠道已经存在,不可重复"));
            }
            if (source.Id > 0)
            {
                source = PCManageRepost.GetQuery(o => o.Id == model.Id).FirstOrDefault();
                model.ToCopyProperty(source, new List <string>()
                {
                    "Id", "ChannelNo", "ChannelCode", "State", "CreateDT", "CreateUID", "AuditDT", "AuditUID"
                });
            }
            else
            {
                var existsCodeObj = PCManageRepost.GetQuery(o => o.ChannelCode == model.ChannelCode).FirstOrDefault();
                if (existsCodeObj != null)
                {
                    return(OpResult.Fail(message: "收单渠道已经存在,不可重复"));
                }

                source.CreateDT  = DateTime.Now;
                source.CreateUID = CurrentUser.UID;
                source.ChannelNo = PayRules.GetMaxNo("PayChannelManages", "ChannelNo");
                PCManageRepost.Add(source, false);
            }

            var result = PCManageRepost.SaveChanges();

            if (result)
            {
                return(OpResult.Success(data: source));
            }
            else
            {
                return(OpResult.Fail(message: "数据未修改,不可保存"));
            }
        }
示例#2
0
        /// <summary>
        /// 支付接口列表-新增或编辑支付接口表单-保存
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public OpResult SaveOrUpdate(PayApi model)
        {
            var source    = model;
            var existsObj = PayApiRepository.GetQuery(o => o.Id != model.Id && o.ChannelNo == model.ChannelNo && o.Method == model.Method).FirstOrDefault();

            if (existsObj != null)
            {
                return(OpResult.Fail(message: "接口参数名称已经存在,不可重复"));
            }
            if (source.Id > 0)
            {
                source = PayApiRepository.GetQuery(o => o.Id == model.Id).FirstOrDefault();
                model.ToCopyProperty(source, new List <string>()
                {
                    "Id", "ApiNo", "ChannelNo", "State", "Version", "CreateDT", "CreateUID", "ReleasedDT", "Releaseder"
                });
            }
            else
            {
                var existsCodeObj = PayApiRepository.GetQuery(o => o.ChannelNo == model.ChannelNo && o.Method == model.Method && o.Version == model.Version).FirstOrDefault();
                if (existsCodeObj != null)
                {
                    return(OpResult.Fail(message: "接口参数名称已经存在,不可重复"));
                }

                source.CreateDT  = DateTime.Now;
                source.CreateUID = CurrentUser.UID;
                source.ApiNo     = PayRules.GetMaxNo("PayApis", "ApiNo");
                PayApiRepository.Add(source, false);
            }

            var result = PayApiRepository.SaveChanges();

            if (result)
            {
                return(OpResult.Success(data: source));
            }
            else
            {
                return(OpResult.Fail(message: "数据未修改不可保存"));
            }
        }