15,918,889 members
Sign in
Sign in
Email
Password
Forgot your password?
Sign in with
home
articles
Browse Topics
>
Latest Articles
Top Articles
Posting/Update Guidelines
Article Help Forum
Submit an article or tip
Import GitHub Project
Import your Blog
quick answers
Q&A
Ask a Question
View Unanswered Questions
View All Questions
View C# questions
View C++ questions
View Javascript questions
View Visual Basic questions
View Python questions
discussions
forums
CodeProject.AI Server
All Message Boards...
Application Lifecycle
>
Running a Business
Sales / Marketing
Collaboration / Beta Testing
Work Issues
Design and Architecture
Artificial Intelligence
ASP.NET
JavaScript
Internet of Things
C / C++ / MFC
>
ATL / WTL / STL
Managed C++/CLI
C#
Free Tools
Objective-C and Swift
Database
Hardware & Devices
>
System Admin
Hosting and Servers
Java
Linux Programming
Python
.NET (Core and Framework)
Android
iOS
Mobile
WPF
Visual Basic
Web Development
Site Bugs / Suggestions
Spam and Abuse Watch
features
features
Competitions
News
The Insider Newsletter
The Daily Build Newsletter
Newsletter archive
Surveys
CodeProject Stuff
community
lounge
Who's Who
Most Valuable Professionals
The Lounge
The CodeProject Blog
Where I Am: Member Photos
The Insider News
The Weird & The Wonderful
help
?
What is 'CodeProject'?
General FAQ
Ask a Question
Bugs and Suggestions
Article Help Forum
About Us
Search within:
Articles
Quick Answers
Messages
Comments by Member 15270194 (Top 7 by date)
Member 15270194
6-Jul-21 6:38am
View
Thank you for your reply. What do you mean by that?
Member 15270194
1-Jul-21 6:58am
View
Thanks for your help.
Member 15270194
1-Jul-21 4:57am
View
Okay, thanks for the advice.
Member 15270194
1-Jul-21 4:39am
View
Without success.
Member 15270194
1-Jul-21 4:18am
View
Thanks a lot for the reply. Here's what I've done so far:
public class Users
{
private readonly AppDbContext _dataContext;
private User _user = new User();
public Users(AppDbContext dataContext)
{
_dataContext = dataContext;
}
public void AddUsers(User user)
{
var users = new User
{
UserName = user.UserName,
Password=user.Password,
Email=user.Email,
Company=user.Company
};
_dataContext.User.Add(users);
_dataContext.SaveChanges();
}
}
I'm interested in the HandleValidSubmit function, should that function remain in Register.razor? Or should we call what I wrote AddUsers in that function?
Member 15270194
30-Jun-21 6:50am
View
Thank you for your reply. I tried to add the following:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using TestBlazor.Models;
namespace TestBlazor.Data
{
public class Users
{
public static void AddUsers()
{
using (var context = new AppDbContext())
{
//var user = new User { Url = "" }; //what this?
context.User.Add(User); //this is error
context.SaveChanges();
}
}
}
}
but I get an error (I added a new class):
Severity Code Description Project File Line Suppression State
Error CS0119 'User' is a type, which is not valid in the given context TestBlazor C: \ ....
Member 15270194
30-Jun-21 4:55am
View
Thank you for your reply. How then should I merge this, i.e. that my data is saved when the user registers? I created a database using add-migration nameofmigration and update-database so now I have that Users table empty.
Show More