示例#1
0
        /// <summary>
        /// Sets the users info to what was entered in the view
        /// </summary>
        /// <returns></returns>
        public async Task <IActionResult> OnPostAsync()
        {
            //Checks to see if model state is valid
            if (!ModelState.IsValid)
            {
                return(Page());
            }

            //Gets the client profile based on the username
            var user = await _context.GetClientAsync(this.Username);

            //Checks to see if user is null
            if (user == null)
            {
                return(Redirect("/Error"));
            }

            var Client = user.Client;

            //Sets client address fields to what was entered in the view
            Client.Address.City           = Address.City;
            Client.Address.State          = Address.State;
            Client.Address.StreetAddress  = Address.StreetAddress;
            Client.Address.StreetAddress2 = Address.StreetAddress2;
            Client.Address.ZipCode        = Address.ZipCode;

            await _context.SaveChangesAsync();

            //Adds the about entered to the client
            await _context.AddClientAboutAsync(Client, About);

            return(RedirectToPage("./Detail"));
        }