TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Prakash
NA
258
73.8k
Using Account Register Method Create user
Sep 20 2016 2:50 AM
Hello Experts,
I am using mvc application using indivisual account authentication.
I have my database also.and in that dbo.dealer table
I want to create dealer and same (Name,Email,Password)data store in to Usermanager table using register method of user manager
i have below my code
// GET: tbl_Dealer/Create
public ActionResult Create()
{
return View();
}
// POST: tbl_Dealer/Create
[HttpPost]
[ValidateAntiForgeryToken]
public ActionResult Create([Bind(Include = "Id,Logo,Name,Email,Phone1,Phone2,IsActive,Address,Pincode,CreatedDateTime,ModifiedDateTime,CreatedBy,ModifiedBy")] tbl_Dealer tbl_Dealer, HttpPostedFileBase file)
{
if (ModelState.IsValid)
{
// ApplicationUserManager UserManager = new ApplicationUserManager();
tbl_Dealer.Id = Guid.NewGuid();
DateTime saveTime = DateTime.Now;
db.tbl_Dealer.Add(tbl_Dealer);
if (tbl_Dealer.CreatedDateTime == null && tbl_Dealer.ModifiedDateTime == null)
{
tbl_Dealer.CreatedDateTime = saveTime;
tbl_Dealer.ModifiedDateTime = saveTime;
}
if (file != null && file.ContentLength > 0)
{
string FileName = Path.GetFileName(file.FileName);
var path = Path.Combine(Server.MapPath("~/Images/" + FileName));
file.SaveAs(path);
tbl_Dealer.Logo = "Images/" + FileName;
}
db.tbl_Dealer.Add(tbl_Dealer);
try {
SaveUser(tbl_Dealer.Name, tbl_Dealer.Email, "agrovet123$");
}
catch { }
db.SaveChanges();
return RedirectToAction("Index");
}
return View(tbl_Dealer);
}
public void SaveUser(string name, string email,string pwd)
{
var user = new ApplicationUser { UserName = name, Email = email };
UserManager.CreateAsync(user, pwd);
}
I get all the data in to user variable but it not store in to User Manager Table
Please Help
Thank You
Reply
Answers (
1
)
application level question for interview
What is use of UiHint and FilterUiHint