public async Task <R> CreateAsync(Agent entity, CurrentUser CurrentUser) { entity.Name = entity.Name.Trim(); entity.ContactNumber = entity.ContactNumber?.Trim(); entity.Key = entity.Key?.Trim(); entity.Secret = entity.Secret?.Trim(); entity.Remarks = entity.Remarks?.Trim(); int count = await _agentRep.RecordCountAsync(new { Name = entity.Name }); if (count > 0) { return(R.Err(msg: entity.Name + " 已存在")); } int r = await _agentRep.InsertAsync(entity); if (r > 0) { await _operateLogApp.InsertAsync <Agent>(CurrentUser, "添加代理商", entity); return(R.Suc()); } return(R.Err()); }
/// <summary> /// /// </summary> /// <param name="entity"></param> /// <returns></returns> public async Task <R> InsertAsync(VisitDomain entity, CurrentUser curUser) { if (await _visitDomainRep.ExistsAsync(entity.Domain.ToLower())) { return(R.Err("域名已存在")); } entity.Id = entity.CreateId(); if (await _visitDomainRep.InsertAsync(entity) == 1) { await _operateLogApp.InsertAsync <VisitDomain>(curUser, "添加代理访问域名", entity); return(R.Suc(entity)); } return(R.Err("添加失败")); }
/// <summary> /// 支付方式添加 /// </summary> /// <param name="entity"></param> /// <returns></returns> public async Task <R> CreateAsync(PaymentSetting entity, CurrentUser currentUser) { entity.Id = entity.CreateId(); entity.CreatorTime = DateTime.Now; var r = await _paymentSettingRep.InsertAsync(entity); if (r != 1) { return(R.Err("添加失败")); } if (currentUser != null) { await _operateLogApp.InsertAsync <PaymentSetting>(currentUser, "添加支付方式", entity); } return(R.Suc(entity)); }
/// <summary> /// 支付方式添加 /// </summary> /// <param name="entity"></param> /// <returns></returns> public async Task <R> CreateAsync(PaymentParameter entity, CurrentUser currentUser) { entity.Id = entity.CreateId(); entity.CreatorTime = DateTime.Now; var r = await _paymentParameterRep.InsertAsync(entity); if (r != 1) { return(R.Err("添加失败")); } if (currentUser != null) { await _operateLogApp.InsertAsync <PaymentParameter>(currentUser, "添加支付参数", entity); } await RemoveCacheAsync(currentUser.Id); return(R.Suc(entity)); }