public BaseService(CosDbContext dbContext) { this.DbContext = dbContext; this.MailingAddressRepository = RepositoryFactory.CreateObj <MailingAddressRepository>(dbContext); this.ExchangeRepository = RepositoryFactory.CreateObj <ExchangeRepository>(dbContext); this.ExchangeExamineRepository = RepositoryFactory.CreateObj <ExchangeExamineRepository>(dbContext); this.CooperationRepository = RepositoryFactory.CreateObj <CooperationRepository>(dbContext); this.ImgRepository = RepositoryFactory.CreateObj <ImgRepository>(dbContext); this.ExchangeReplyRepository = RepositoryFactory.CreateObj <ExchangeReplyRepository>(dbContext); this.CooperationReplyRepository = RepositoryFactory.CreateObj <CooperationReplyRepository>(dbContext); this.ExchangePersonRepository = RepositoryFactory.CreateObj <ExchangePersonRepository>(dbContext); this.MemberRepository = RepositoryFactory.CreateObj <MemberRepository>(dbContext); this.RechargeRecordRepository = RepositoryFactory.CreateObj <RechargeRecordRepository>(dbContext); this.SysParaRepository = RepositoryFactory.CreateObj <SysParaRepository>(dbContext); this.ExchangeEventRepository = RepositoryFactory.CreateObj <ExchangeEventRepository>(dbContext); this.DepositControlRepository = RepositoryFactory.CreateObj <DepositControlRepository>(dbContext); this.LogisticRepository = RepositoryFactory.CreateObj <LogisticRepository>(dbContext); this.LoginCodeRepository = RepositoryFactory.CreateObj <LoginCodeRepository>(dbContext); this.ShipperCompanyRepository = RepositoryFactory.CreateObj <ShipperCompanyRepository>(dbContext); this.AdminMemberRepository = RepositoryFactory.CreateObj <AdminMemberRepository>(dbContext); this.CooperationClassRepository = RepositoryFactory.CreateObj <CooperationClassRepository>(dbContext); this.RefundRepository = RepositoryFactory.CreateObj <RefundRepository>(dbContext); this.QuickNavigationRepository = RepositoryFactory.CreateObj <QuickNavigationRepository>(dbContext); this.PostageRepository = RepositoryFactory.CreateObj <PostageRepository>(dbContext); this.CosFileStatRepository = RepositoryFactory.CreateObj <CosFileStatRepository>(dbContext); this.ExchangeClassRepository = RepositoryFactory.CreateObj <ExchangeClassRepository>(dbContext); this.VoucherRepository = RepositoryFactory.CreateObj <VoucherRepository>(dbContext); this.LoginIpRepository = RepositoryFactory.CreateObj <LoginIPRepository>(dbContext); this.IntegralChangeRepository = RepositoryFactory.CreateObj <IntegralChangeRepository>(dbContext); this.LoggingRepository = RepositoryFactory.CreateObj <LoggingRepository>(dbContext); this.MemberRegisterRepository = RepositoryFactory.CreateObj <MemberRegisterRepository>(dbContext); this.VersionNotesRepository = RepositoryFactory.CreateObj <VersionNotesRepository>(dbContext); }
public ExchangeExamineService(CosDbContext nContext) : base(nContext) { }
public MailingAddressService(CosDbContext dbContext) : base(dbContext) { }
public RemoteController(CosDbContext dbContext) { _memberService = new MemberService(dbContext); _loginCodeService = new LoginCodeService(dbContext); _voucherService = new VoucherService(dbContext); }
public ExchangeEventService(CosDbContext dbContext) : base(dbContext) { }
public ExchangeClassService(CosDbContext dbContext) : base(dbContext) { }
/// <summary> /// /// </summary> /// <param name="dbContext"></param> public ExchangeClassController(CosDbContext dbContext) { _exchangeClassService = new ExchangeClassService(dbContext); }
public LoginIPService(CosDbContext dbContext) : base(dbContext) { }
public ExchangePersonService(CosDbContext dbContext) : base(dbContext) { }
public MemberService(CosDbContext dbContext) : base(dbContext) { }
public VoucherService(CosDbContext dbContext) : base(dbContext) { }
public CosFileStatService(CosDbContext dbContext) : base(dbContext) { }
public HotSearchService(CosDbContext dbContext) : base(dbContext) { _hotSearchRepository = RepositoryFactory.CreateObj <HotSearchRepository>(dbContext); }
public QuickNavigationService(CosDbContext dbContext) : base(dbContext) { }
public DepositControlService(CosDbContext dbContext) : base(dbContext) { }
/// <summary> /// /// </summary> /// <param name="dbContext"></param> public ExchangeExamineController(CosDbContext dbContext) { _exchangeExamineService = new ExchangeExamineService(dbContext); }
public PostageService(CosDbContext dbContext) : base(dbContext) { }
public ShipperCompanyService(CosDbContext dbContext) : base(dbContext) { }
public ExchangeReplyService(CosDbContext dbContext) : base(dbContext) { }
public CooperationClassService(CosDbContext dbContext) : base(dbContext) { }
public SysParaService(CosDbContext dbContext) : base(dbContext) { }
public VersionNotesService(CosDbContext dbContext) : base(dbContext) { }
public ImgService(CosDbContext dbContext) : base(dbContext) { _imgRepository = RepositoryFactory.CreateObj <ImgRepository>(dbContext); }
public ExchangeService(CosDbContext dbContext) : base(dbContext) { _integralChangeService = new IntegralChangeService(dbContext); }
public LogisticService(CosDbContext dbContext) : base(dbContext) { }
public CooperationReplyService(CosDbContext dbContext) : base(dbContext) { }
/// <summary> /// /// </summary> /// <param name="dbContext"></param> public HotSearchController(CosDbContext dbContext) { _hotSearchService = new HotSearchService(dbContext); }
public RechargeRecordService(CosDbContext dbContext) : base(dbContext) { }
public LoginCodeService(CosDbContext dbContext) : base(dbContext) { _loginCodeRepository = RepositoryFactory.CreateObj <LoginCodeRepository>(dbContext); }
/// <summary> /// Overridden IsValid function /// </summary> /// <param name="value"></param> /// <param name="validationContext"></param> /// <returns></returns> protected override ValidationResult IsValid(object value, ValidationContext validationContext) { string connection = OtherConfig.CosSSMSConnString; DbContextOptions <CosDbContext> dbContextOption = new DbContextOptions <CosDbContext>(); DbContextOptionsBuilder <CosDbContext> dbContextOptionBuilder = new DbContextOptionsBuilder <CosDbContext>(dbContextOption); CosDbContext dbContext = new CosDbContext(dbContextOptionBuilder.UseSqlServer(connection).Options); // Find the controller passed in constructor var controller = GetControllerList().FirstOrDefault(x => x.Name == string.Format("{0}Controller", this.RouteData["controller"])); if (controller == null) { // Default behavior of IsValid when no controller is found. return(ValidationResult.Success); } List <Type> proTypeList = new List <Type>() { value.GetType() }; List <object> proList = new List <object>() { value }; if (!string.IsNullOrWhiteSpace(AdditionalFields)) { var fields = AdditionalFields.Split(',', StringSplitOptions.RemoveEmptyEntries); proTypeList.AddRange(validationContext.ObjectType.GetProperties().Where(info => fields.Any(s => info.Name.Contains(s))).Select(info => info.PropertyType)); proList.AddRange(validationContext.ObjectType.GetProperties().Where(info => fields.Any(s => info.Name.Contains(s))).Select(info => info.GetValue(validationContext.ObjectInstance))); } // Find the Method passed in constructor var mi = controller.GetMethod(this.RouteData["action"].ToString(), BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance, null, proTypeList.ToArray(), null); if (mi == null) { // Default behavior of IsValid when action not found return(ValidationResult.Success); } // Create instance of the controller to be able to call non static validation method var instance = Activator.CreateInstance(controller, dbContext); // invoke the method on the controller with value and "AdditionalFields" JsonResult result = mi.Invoke(instance, proList.ToArray()) is Task <object> task ? (JsonResult)task.Result : (JsonResult)mi.Invoke(instance, proList.ToArray()); // Return success or the error message string from CustomRemoteAttribute if (!(result.Value is string errorMessaqe)) { bool isValid; try { isValid = (bool)result.Value; } catch (Exception) { isValid = false; } return(isValid ? ValidationResult.Success : new ValidationResult(base.ErrorMessageString)); }