Esempio n. 1
0
 public CheckoutController(IBucketProvider bucketProvider, IHostingEnvironment env, IEmailSender emailSender, Configuration configuration)
 {
     // singleton that is the DB bucket similar to MySQL
     _checkoutBucket    = bucketProvider.GetBucket("Checkout");
     _userInfoBucket    = bucketProvider.GetBucket("UserInfo");
     _env               = env;
     _emailSender       = emailSender;
     this.configuration = configuration;
 }
Esempio n. 2
0
        //Upon user selected options, display appropriate data.
        public IActionResult GetState(MerchandiseViewModel model)
        {
            model.countries       = _countries;
            model.cards           = _cards;
            model.networks        = _networks;
            model.SelectedCountry = (from c in model.countries
                                     where c.Value == model.SelectedCountryId.ToString()
                                     select new Country
            {
                CountryId = int.Parse(c.Value),
                CountryName = c.Text
            }).FirstOrDefault();

            model.SelectedCard = (from d in model.cards
                                  where d.Value == model.SelectedCardId.ToString()
                                  select new Card
            {
                CardId = int.Parse(d.Value),
                CardLetter = d.Text
            }).FirstOrDefault();

            model.SelectedNetwork = (from n in model.networks
                                     where n.Value == model.SelectedNetworkId.ToString()
                                     select new Network
            {
                NetworkId = int.Parse(n.Value),
                NetworkName = n.Text
            }).FirstOrDefault();

            NetworkId = model.SelectedNetworkId;
            CompanyId = model.SelectedCountryId;
            CardId    = model.SelectedCardId;

            string countryName = FindCountryName(model.SelectedCountry.CountryId);
            string cardLetter  = GetCard(model.SelectedCard.CardId);
            int    countryCode = FindCountryCode(model.SelectedCountry.CountryId);
            var    bucket      = _bucketProvider.GetBucket(countryName);
            var    n1ql        = @"SELECT g.*, META(g).id
                        FROM `" + countryName + "` g " +
                                 "WHERE g.companyId = " + countryCode + " " +
                                 "AND g.showCd = '" + cardLetter + "' " +
                                 "AND g.networkId = " + model.SelectedNetwork.NetworkId + " " +
                                 "LIMIT 20;";

            var query   = QueryRequest.Create(n1ql);
            var results = bucket.Query <Merchandise>(query);

            try
            {
                model.merchandise = results.Rows;
            }
            catch (global::System.Exception)
            {
                throw;
            }
            return(View(model));
        }
        public IActionResult GetUSA()
        {
            var bucket  = _bucketProvider.GetBucket("MerchUSA");
            var n1ql    = @"SELECT g.*, META(g).id
                        FROM `MerchUSA` g
                        WHERE g.companyId = 0;";
            var query   = QueryRequest.Create(n1ql);
            var results = bucket.Query <Merchandise>(query);

            return(Ok(results.Rows));
        }
        public async Task <IActionResult> GetAirlines()
        {
            var bucket = _bucketProvider.GetBucket("travel-sample");

            var context = new BucketContext(bucket);

            var query =
                from p in context.Query <Airline>()
                orderby p.Name
                select p;

            var result = await query.ExecuteAsync();

            return(Ok(result.Select(p => _mapper.Map <AirlineDto>(p))));
        }
Esempio n. 5
0
        public Repository(IBucketProvider bucketProvider, ICluster clustur)
        {
            string name = typeof(Type)
                          .GetAttributeValue((BucketNameAttribute dna) => dna.Name);

            if (string.IsNullOrEmpty(name))
            {
                throw new BucketNotFoundException("BucketName Eklememiş");
            }
            clustur.Authenticate("Administrator", "Qn4j123");
            _clusterManager = clustur.CreateManager(); //burda kaldım clustur oluşturmuyor
            var bucketList = _clusterManager.ListBuckets();

            if (bucketList.Success && !bucketList.Value.Any(x => x.Name == name))
            {
                var bucketResult = CreateBucket(name);
                if (!bucketResult.Item1)
                {
                    throw new BucketNotFoundException($"Bucket Oluşturulken hata alındı {bucketResult.Item2}");
                }
                else
                {
                    ExecQueryReturnList($"CREATE PRIMARY INDEX `{name}_primary_index` ON `{name}`");
                }
            }

            _bucket = bucketProvider.GetBucket(name);
        }
Esempio n. 6
0
        public CarPriceController(ISlowLegacyService service, IBucketProvider bucketProvider)
        {
            _service = service;

            // this is only in the homecontroller for GetCachedItemsFromCouchbase
            // which is purely for demonstration/presentation purposes
            _bucket = bucketProvider.GetBucket("mycache");
        }
        public async Task <IActionResult> RequestWithLock(int requester)
        {
            var bucket = _bucketProvider.GetBucket("default");

            _logger.LogInformation("Starting requester {requester}", requester);

            try
            {
                var startTime = DateTime.Now;

                // Retry policy will try 10 times to get the lock, and will wait 1 second between attempts
                // Lock will be held for 2 seconds if not renewed
                using (var mutex = await RetryPolicy.ExecuteAsync(() =>
                                                                  bucket.RequestMutexAsync("my_lock_name", TimeSpan.FromSeconds(2))))
                {
                    // Will renew the lock every second, up to a maximum of 15 seconds, so long as the process keeps running
                    mutex.AutoRenew(TimeSpan.FromSeconds(1), TimeSpan.FromSeconds(15));

                    var lockTime = DateTime.Now;

                    await Task.Delay(5000);

                    return(View(new RequestWithLockModel {
                        WasLocked = true,
                        LockDelayTime = lockTime - startTime,
                        LockHoldTime = DateTime.Now - lockTime
                    }));

                    // Lock will be released once we exit the using statement, and auto renew will cease
                }
            }
            catch (CouchbaseLockUnavailableException)
            {
                return(View(new RequestWithLockModel
                {
                    WasLocked = false
                }));
            }
        }
 public SlowLegacyService(IBucketProvider bucketProvider)
 {
     _bucket = bucketProvider.GetBucket("mycache");
 }
 public BasketDiscController(IBucketProvider bucketProvider)
 {
     // singleton that is the DB bucket similar to MySQL
     _bucket = bucketProvider.GetBucket("Basket");
 }
Esempio n. 10
0
 public HomeController(IBucketProvider bucketProvider)
 {
     _bucket = bucketProvider.GetBucket("travel-sample");
 }
 public GeoSpatialController(IBucketProvider bucketProvider)
 {
     _bucket = bucketProvider.GetBucket("travel-sample");
 }
 public LoyaltyCsvImportService(IBucketProvider bucketProvider, ILogger <LoyaltyCsvImportService> logger)
 {
     _logger = logger;
     _bucket = bucketProvider.GetBucket("staging");
 }
Esempio n. 13
0
 public BookRepository(IBucketProvider bucketProvider)
 {
     _bucket = bucketProvider.GetBucket("Books", "12345678");
 }
Esempio n. 14
0
 public TicketController(IBucketProvider bucketProvider)
 {
     _bucket = bucketProvider.GetBucket("tickets");
 }
Esempio n. 15
0
 public HomeController(ILogger <HomeController> logger, IBucketProvider bucketProvider)
 {
     _logger = logger;
     _bucket = bucketProvider.GetBucket("hellomicroservice");
 }
Esempio n. 16
0
 public CouchbaseMessageService(IBucketProvider bucketProvider)
 {
     _bucket = bucketProvider.GetBucket("CarMessengerBucket");
 }
 public UpcomingEventsController(IBucketProvider bucketProvider)
 {
     _bucket = bucketProvider.GetBucket("events");
 }
Esempio n. 18
0
 public PeopleRepository(IBucketProvider provider)
 {
     this.peopleBucket = provider.GetBucket("people-sample");
 }
Esempio n. 19
0
 public UserController(IBucketProvider bucketProvider)
 {
     _bucket = bucketProvider.GetBucket("default");
 }
Esempio n. 20
0
 public ContainerRepository(IBucketProvider bucketProvider)
 {
     _bucket = bucketProvider.GetBucket("sitadb");
 }
Esempio n. 21
0
 public SportController(IBucketProvider bucketProvider, ILogger <ClientController> logger)
 {
     _bucket = bucketProvider.GetBucket("feeds");
 }
Esempio n. 22
0
 public AirportController(IBucketProvider bucketProvider)
 {
     _bucket = bucketProvider.GetBucket("travel-sample", "Administrator");
 }
Esempio n. 23
0
 public UserProfileController(ILogger <UserProfileController> logger, IBucketProvider bucket, IMediator mediator)
 {
     _logger   = logger;
     _mediator = mediator;
     _bucket   = bucket.GetBucket("usereventsource");
 }
Esempio n. 24
0
 public SessionMetricsRepository(IBucketProvider bucketProvider)
 {
     this._bucket = bucketProvider.GetBucket("ViajaNet");
 }
Esempio n. 25
0
 public UserRepository(IBucketProvider bucketProvider)
 {
     _bucket        = bucketProvider.GetBucket("user_profile");
     _bucketContext = new BucketContext(_bucket);
 }
Esempio n. 26
0
        //private readonly IBucketContext _ctx;

        public PersonController(IBucketProvider bucketProvider)
        {
            _bucket = bucketProvider.GetBucket("workshop");
            //_ctx = context;
        }
Esempio n. 27
0
 public HomeController(IBucketProvider bucketProvider)
 {
     _bucket = bucketProvider.GetBucket("default", "password");
 }
Esempio n. 28
0
 public LandmarkController(IBucketProvider bucket)
 {
     this.bucket = bucket.GetBucket("travel-sample");
 }
Esempio n. 29
0
 public SocialMediaRequestHandler(IBucketProvider bucketProvider)
 {
     _bucket = bucketProvider.GetBucket("usereventsource");
 }
 public WeatherForecastController(ILogger <WeatherForecastController> logger, IBucketProvider bucketProvider)
 {
     _logger = logger;
     _bucket = bucketProvider.GetBucket("jul");
 }