当前位置: 首页>>代码示例>>C#>>正文


C# ICustomerRepository.Get方法代码示例

本文整理汇总了C#中ICustomerRepository.Get方法的典型用法代码示例。如果您正苦于以下问题:C# ICustomerRepository.Get方法的具体用法?C# ICustomerRepository.Get怎么用?C# ICustomerRepository.Get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ICustomerRepository的用法示例。


在下文中一共展示了ICustomerRepository.Get方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: BeforeEach

        public void BeforeEach()
        {
            _productRepo = Substitute.For<IProductRepository>();
            _orderFulfillmentService = Substitute.For<IOrderFulfillmentService>();
            _customerRepository = Substitute.For<ICustomerRepository>();
            _taxRateService = Substitute.For<ITaxRateService>();
            _emailService = Substitute.For<IEmailService>();

            _subject = new OrderService(_orderFulfillmentService,
                _customerRepository,
                _taxRateService,
                _emailService);

            _bestCustomer = new Customer
            {
                CustomerId = 42,
                PostalCode = "12345",
                Country = "Merica"
            };

            _listOfTaxEntries = new List<TaxEntry>
            {
                new TaxEntry {Description = "High Tax", Rate = (decimal) 0.60},
                new TaxEntry {Description = "Low Tax", Rate = (decimal) 0.10}
            };

            _orderConfirmation = new OrderConfirmation
            {
                OrderId = 1234,
                OrderNumber = "hello"
            };
            _customerRepository.Get(_bestCustomer.CustomerId.Value).Returns(_bestCustomer);
            _taxRateService.GetTaxEntries(_bestCustomer.PostalCode, _bestCustomer.Country).Returns(_listOfTaxEntries);
        }
开发者ID:brntsllvn,项目名称:OrderEntryMockingPracticeOLD,代码行数:34,代码来源:OrderServiceTests.cs

示例2: CustomerModule

        public CustomerModule(IBus bus, IAdvancedBus eBus, ICustomerRepository customers, IRepository<User> userRepository)
        {
            if (_defaultJsonMaxLength == 0)
                _defaultJsonMaxLength = JsonSettings.MaxJsonLength;

            //Hackeroonie - Required, due to complex model structures (Nancy default restriction length [102400])
            JsonSettings.MaxJsonLength = Int32.MaxValue;

            Get["/Customers"] = _ =>
            {
                var search = Context.Request.Query["search"];
                var offset = Context.Request.Query["offset"];
                var limit = Context.Request.Query["limit"];

                if (offset == null) offset = 0;
                if (limit == null) limit = 10;

                var model = this.Bind<DataTablesViewModel>();
                var dto = Mapper.Map<IEnumerable<Customer>, IEnumerable<CustomerDto>>(customers.Where(x => x.IsActive));//.Search(Context.Request.Query["search[value]"].Value, model.Start, model.Length));
                return Negotiate
                    .WithView("Index")
                    .WithMediaRangeModel(MediaRange.FromString("application/json"), new { data = dto.ToList() });
            };

            Get["/CustomerLookup/{industryIds?}/{filter:alpha}"] = parameters =>
            {
                var dto = Enumerable.Empty<NamedEntityDto>();
                if (parameters.industryIds.Value != null)
                {
                    var industryString = (string)parameters.industryIds.Value;
                    var industryIds = industryString.Split(',').Select(x => new Guid(x)).ToArray();
                    var filter = (string)parameters.filter + "";
                    var valueEntities = customers.Where(x => (x.Name + "").Trim().ToLower().StartsWith(filter.Trim().ToLower()) && x.Industries.Any(ind => industryIds.Contains(ind.IndustryId)));
                    dto = Mapper.Map<IEnumerable<NamedEntity>, IEnumerable<NamedEntityDto>>(valueEntities);
                }
                
                return Negotiate
                    .WithView("Index")
                    .WithMediaRangeModel(MediaRange.FromString("application/json"), new { dto });
            };

            Get["/Customers/Add"] = parameters =>
            {
                return View["Save", new CustomerDto()];
            };

            Post["/Customers"] = _ =>
            {
                var dto = this.BindAndValidate<CustomerDto>();
                dto.CreatedBy = Context.CurrentUser.UserName;
                dto.IsActive = true;

                if(dto.TrialExpiration == null) dto.TrialExpiration = DateTime.UtcNow.Date;

                if (ModelValidationResult.IsValid)
                {
                    var user = userRepository.Get(dto.accountownerlastname_primary_key);
                    var entity = Mapper.Map(dto, new Customer(dto.Name));
                    entity.SetCreateSource(CreateSourceType.UserManagement);
                    entity.SetAccountOwner(user);

                    bus.Publish(new CreateUpdateEntity(entity, "Create"));

                    return View["Index"];
                }

                return View["Save", dto];
            };

            Get["/Customers/{id}"] = parameters =>
            {
                var guid = (Guid)parameters.id;
                var dto = Mapper.Map<Customer, CustomerDto>(customers.Get(guid));

                return View["Save", dto];
            };

            Get["/Customers/Details/{id}"] = parameters =>
            {
                var guid = (Guid)parameters.id;
                var dto = Mapper.Map<Customer, CustomerDto>(customers.Get(guid));

                return Response.AsJson(dto);
            };

            Put["/Customers/{id}"] = parameters =>
            {
                var dto = this.BindAndValidate<CustomerDto>();
                dto.ModifiedBy = Context.CurrentUser.UserName;

                if (dto.TrialExpiration == null) dto.TrialExpiration = DateTime.UtcNow.Date;

                if (ModelValidationResult.IsValid)
                {
                    var user = userRepository.Get(dto.accountownerlastname_primary_key);
                    var entity = Mapper.Map(dto, customers.Get(dto.Id));
                    entity.SetAccountOwner(user);

                    bus.Publish(new CreateUpdateEntity(entity, "Update"));

//.........这里部分代码省略.........
开发者ID:rjonker1,项目名称:lightstone-data-platform,代码行数:101,代码来源:CustomerModule.cs


注:本文中的ICustomerRepository.Get方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。