public async Task <IActionResult> OnPost(IFormFile avatar) { if (avatar != null) { BinaryReader br = new BinaryReader(avatar.OpenReadStream()); userProfile.AvatarOne = br.ReadBytes((int)avatar.OpenReadStream().Length) ?? userProfile.AvatarOne; } userProfile.Username = token.username ?? userProfile.Username; userProfile.Firstname = (Request.Form["firstname"]).ToString() ?? userProfile.Firstname; userProfile.Lastname = (Request.Form["lastname"]).ToString() ?? userProfile.Lastname; userProfile.Email = (Request.Form["email"]).ToString() ?? userProfile.Email; userProfile.Cell = (Request.Form["cell"]).ToString() ?? userProfile.Cell; userProfile.AddressOne = (Request.Form["addressone"]).ToString() ?? userProfile.AddressOne; userProfile.AddressTwo = (Request.Form["addresstwo"]).ToString() ?? userProfile.AddressTwo; userProfile.Zip = (Request.Form["zip"]).ToString() ?? userProfile.Zip; userProfile.NameOnCard = (Request.Form["nameoncard"]).ToString() ?? userProfile.NameOnCard; userProfile.CVV = (Request.Form["cvv"]).ToString() ?? userProfile.CVV; userProfile.CardNumber = (Request.Form["cardnumber"]).ToString() ?? userProfile.CardNumber; userProfile.ExpirationOnCard = DateTime.Parse(Request.Form["expdate"]); userProfile.PaymentType = Request.Form["paymenttype"]; var helper = new UserProfileHelper(configuration, token); if (await helper.EditProfile(userProfile)) { return(RedirectToPage("/Profile")); } else { return(RedirectToPage("/Error")); } }