Пример #1
0
        public async Task <ActionResult <BillingAddress> > CreaterBillingAddress(BillingAddress billingAddress)
        {
            try
            {
                if (billingAddress == null)
                {
                    return(BadRequest());
                }

                // create a object of account info
                AccountInfoController accountInfoObj = new AccountInfoController(accountRepository);
                //get the account info custRegistrationId and assign that value to the billingAddress foreing key custRegistrationId
                billingAddress.CustRegistrationId = accountInfoObj.getCustRegId();
                var createBillingAddress = await billingAddressRepository.AddBillingAddress(billingAddress);

                return(CreatedAtAction(nameof(GetBillingAddress), new { id = createBillingAddress.BillingID }, createBillingAddress));
            }
            catch (Exception e)
            {
                return(StatusCode(StatusCodes.Status500InternalServerError,
                                  "Error retreving data from the database \n " + e));
            }
        }
        public async Task <ActionResult <BillingAddress> > CreaterBillingAddress(BillingAddress billingAddress)
        {
            try
            {
                if (billingAddress == null)
                {
                    return(BadRequest());
                }

                AccountInfoController ff = new AccountInfoController(accountRepository);

                //billingAddress.CustRegistrationId = Convert.ToInt32(custID);
                billingAddress.CustRegistrationId = ff.getCustRegId();
                var createBillingAddress = await billingAddressRepository.AddBillingAddress(billingAddress);

                return(CreatedAtAction(nameof(GetBillingAddress), new { id = createBillingAddress.BillingID }, createBillingAddress));
            }
            catch (Exception e)
            {
                return(StatusCode(StatusCodes.Status500InternalServerError,
                                  "Error retreving data from the database \n " + e));
            }
        }