示例#1
0
        public async Task <ActionResult <AccountInfo> > CreateShippingAddress(ShippingAddress shippingAddress)
        {
            try
            {
                if (shippingAddress == null)
                {
                    return(BadRequest());
                }

                AccountInfoController ff = new AccountInfoController(accountRepository);

                shippingAddress.CustRegistrationId = ff.getCustRegId();
                var createShippingAdress = await shippingAddressRepository.AddShippingAddress(shippingAddress);

                return(CreatedAtAction(nameof(GetShippingAddresses), new { id = createShippingAdress.ShippingId }));
            }
            catch (Exception e)
            {
                return(StatusCode(StatusCodes.Status500InternalServerError,
                                  "Error retreving data from the database \n " + e));
            }
        }
示例#2
0
        public async Task <ActionResult <AccountInfo> > CreateShippingAddress(ShippingAddress shippingAddress)
        {
            try
            {
                if (shippingAddress == 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 shippingAddress foreing key custRegistrationId
                shippingAddress.CustRegistrationId = accountInfoObj.getCustRegId();
                var createShippingAdress = await shippingAddressRepository.AddShippingAddress(shippingAddress);

                return(CreatedAtAction(nameof(GetShippingAddresses), new { id = createShippingAdress.ShippingId }));
            }
            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));
            }
        }