Example #1
0
        public ActionResult <UserAddress> Put(int userId, [FromBody] UserAddress value)
        {
            var userResult = _userAddressService.InsertUser(value.User);

            if (userResult.IsSuccess)
            {
                value.Address.Owner = userResult.UserId;
                var addressResult = _userAddressService.InsertAddress(value.Address);
                if (addressResult.IsSuccess)
                {
                    value.User    = userResult;
                    value.Address = addressResult;
                    return(Ok(value));
                }
                else
                {
                    var deleteResponse = _userAddressService.DeleteUser(userResult.UserId);
                    return(NotFound(deleteResponse));
                }
            }
            else
            {
                return(NotFound());
            }
        }
Example #2
0
        public ActionResult UserAddress(int userId, UserAddress useraddress)
        {
            var userResult = _userAddressService.InsertUser(useraddress.User);

            if (userResult.IsSuccess)
            {
                useraddress.Address.Owner = userResult.UserId;
                Address addressResult = new Address();
                if (useraddress.Address.AddressId > 0)
                {
                    addressResult = _userAddressService.UpdateAddress(useraddress.Address);
                }
                else
                {
                    addressResult = _userAddressService.InsertAddress(useraddress.Address);
                }

                if (addressResult.IsSuccess)
                {
                    useraddress.User    = userResult;
                    useraddress.Address = addressResult;
                    return(View(useraddress));
                }
                else
                {
                    var deleteResponse = _userAddressService.DeleteUser(userResult.UserId);
                    return(View(useraddress));
                }
            }
            else
            {
                return(View(useraddress));
            }
        }