public async Task <ActionResult <DimAccount> > GetDimCustomerById(int id)
        {
            DimAccount customer = await _service.GetDimCustomerByIdAsync(id);

            if (customer == null)
            {
                return(NotFound());
            }

            return(customer);
        }
Esempio n. 2
0
        public async Task GetDimCustomerByIdAsync_SomeIntNumber_DimAccountWithSomeIntKey()
        {
            _moqService.Setup(a => a.GetDimCustomerByIdAsync(It.IsAny <int>()))
            .ReturnsAsync((int x) => { return(new DimAccount()
                {
                    AccountKey = x
                }); });

            int someInt = 10;

            IDimAccountService _dimAccountService = _moqService.Object;

            DimAccount actualDimAccount = await _dimAccountService.GetDimCustomerByIdAsync(someInt);

            Assert.AreEqual(someInt, actualDimAccount.AccountKey);
        }
Esempio n. 3
0
        public string EditAccount(string store, int id, DimAccount model)
        {
            bool   isServerOnline            = SqlAlwaysOnService.IsServerConnected(Constants.SQLAlwaysOnConnectionString);
            string primaryConnectionString   = string.Empty;
            string secondaryConnectionString = string.Empty;

            if (isServerOnline)
            {
                if (SqlAlwaysOnService.IsPrimaryDatabase(Constants.SqlAlwaysOnPrimaryConnectionString))
                {
                    primaryConnectionString   = Constants.SqlAlwaysOnPrimaryConnectionString;
                    secondaryConnectionString = Constants.SqlAlwaysOnSecondaryConnectionString;
                }
                else
                {
                    primaryConnectionString   = Constants.SqlAlwaysOnSecondaryConnectionString;
                    secondaryConnectionString = Constants.SqlAlwaysOnPrimaryConnectionString;
                }
            }

            string connectionString = !string.IsNullOrEmpty(store) && store == "Secondary" ? secondaryConnectionString : primaryConnectionString;

            return(SqlAlwaysOnService.UpdateAccount(connectionString, id, model));
        }
        public async Task AddDimCustomerAsync(DimAccount customer)
        {
            await _context.DimAccount.AddAsync(customer);

            await _context.SaveChangesAsync();
        }
        public async Task <ActionResult <DimAccount> > AddDimCustomer(DimAccount customer)
        {
            await _service.AddDimCustomerAsync(customer);

            return(CreatedAtAction(nameof(GetDimCustomerById), new { id = customer.AccountKey }, customer));
        }