public async Task <ActionResult> Register(RegisterViewModel model) { if (ModelState.IsValid) { var user = new ApplicationUser { UserName = model.Email, Email = model.Email }; //------------------------------------------------------------------ <= TUTAJ var result = await UserManager.CreateAsync(user, model.Password); if (result.Succeeded) { ApplicationUser user2 = UserManager.FindByName(model.Email); UserManager.AddToRole(user2.Id, "user"); UzytkownicyModels uz = new UzytkownicyModels(); uz.Nazwa = model.Email; db.Uzytkownik.Add(uz); db.SaveChanges(); await SignInManager.SignInAsync(user, isPersistent : false, rememberBrowser : false); return(RedirectToAction("Index", "Home")); } AddErrors(result); } // Dotarcie do tego miejsca wskazuje, że wystąpił błąd, wyświetl ponownie formularz return(View(model)); }
public ActionResult Delete(int id) { UzytkownicyModels ownerModel = db.Uzytkownik.Find(id); db.Uzytkownik.Remove(ownerModel); db.SaveChanges(); //zapis zmian return(RedirectToAction("Index")); }
public ActionResult Edit([Bind(Include = "ID,Nazwa,Data_dolaczenia")] UzytkownicyModels ownerModelUpdated) { if (ModelState.IsValid) { db.Entry(ownerModelUpdated).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(ownerModelUpdated)); }
public ActionResult Create([Bind(Include = "Nazwa,Data_dolaczenia")] UzytkownicyModels ownerModel) { if (ModelState.IsValid) { db.Uzytkownik.Add(ownerModel); db.SaveChanges(); //zapis zmian return(RedirectToAction("Index")); } return(View(ownerModel)); //zostaną dane w formularzu }
public ActionResult Delete(int?id) { if (id == null) { return(RedirectToAction("Index")); } UzytkownicyModels ownerModel = db.Uzytkownik.Find(id); if (ownerModel == null) { return(HttpNotFound()); } return(View(ownerModel)); }