Example #1
0
        public async Task <bool> Delete(int addressId, int customerId, string language)
        {
            var currentUser = await _authenticationService.GetUser(User.Identity.Name);

            if (currentUser.CustomerId != customerId)
            {
                throw new HttpResponseException(HttpStatusCode.InternalServerError, "Provided customer is not assigned to your account");
            }
            language.ConvertLocaleStringToServerLanguage();

            try
            {
                if (currentUser.CustomerId != null)
                {
                    var address = await this.Get(addressId, currentUser.CustomerId.Value, "EN");

                    await _addressesService.DeleteAddress(address);
                }
                else
                {
                    throw new HttpResponseException(HttpStatusCode.Forbidden, "Don't have permission to delete this addres");
                }
            }
            catch (Exception)
            {
                throw new HttpResponseException(HttpStatusCode.Forbidden, "Don't have permission to delete this addres");
            }

            return(true);
        }
Example #2
0
        public async Task Test_DeleteAddress_Is_Ok()
        {
            try
            {
                AddressModel currentAddressModel =
                    await _addressesService.Get(74);

                await _addressesService.DeleteAddress(currentAddressModel);
            }
            catch (Exception)
            {
                Assert.IsFalse(true);
            }
            Assert.IsTrue(true);
        }