Skip to content

Commit

Permalink
Suppressed non-nullable warnings related to shipping address
Browse files Browse the repository at this point in the history
  • Loading branch information
Rostech committed Oct 4, 2022
1 parent 1acdefc commit 2bec08d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@ public class ShippingAddressModel : PageModel
private readonly IMemberRegistrationService _memberRegistrationService;
private readonly IRepository<Member> _memberRepository;

#pragma warning disable CS8618 // Non-nullable field must contain a non-null value when exiting constructor. Consider declaring as nullable.
public ShippingAddressModel(UserManager<ApplicationUser> userManager,
#pragma warning restore CS8618 // Non-nullable field must contain a non-null value when exiting constructor. Consider declaring as nullable.
IMemberRegistrationService memberRegistrationService,
IRepository<Member> memberRepository)
{
Expand Down Expand Up @@ -65,7 +67,9 @@ public async Task OnPost()
UserShippingAddressUpdateModel.PostalCode,
UserShippingAddressUpdateModel.Country));

#pragma warning disable CS8602 // Dereference of a possibly null reference.
member.UpdateAddress(member.ShippingAddress.ToString());
#pragma warning restore CS8602 // Dereference of a possibly null reference.

await _memberRepository.UpdateAsync(member);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,17 @@ namespace DevBetterWeb.Web.Pages.User;

public class UserShippingAddressUpdateModel
{
#pragma warning disable CS8618 // Non-nullable field must contain a non-null value when exiting constructor. Consider declaring as nullable.
public UserShippingAddressUpdateModel()
#pragma warning restore CS8618 // Non-nullable field must contain a non-null value when exiting constructor. Consider declaring as nullable.
{
}

public UserShippingAddressUpdateModel(Member member)
{
#pragma warning disable CS8602 // Dereference of a possibly null reference.
this.Street = member.ShippingAddress.Street;
#pragma warning restore CS8602 // Dereference of a possibly null reference.
this.City = member.ShippingAddress.City;
this.State = member.ShippingAddress.State;
this.PostalCode = member.ShippingAddress.PostalCode;
Expand Down

0 comments on commit 2bec08d

Please sign in to comment.