public ActionResult DeleteConfirmed(int id) { CriticModels criticModels = db.Critics.Find(id); db.Critics.Remove(criticModels); db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Edit([Bind(Include = "ID,Name,SecondName,Alias,Picture,Descritpion,Appreciation")] CriticModels criticModels) { if (ModelState.IsValid) { db.Entry(criticModels).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(criticModels)); }
public ActionResult Create([Bind(Include = "ID,Name,SecondName,Alias,Picture,Descritpion,Appreciation")] CriticModels criticModels) { if (ModelState.IsValid) { db.Critics.Add(criticModels); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(criticModels)); }
// GET: CriticModels/Delete/5 public ActionResult Delete(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } CriticModels criticModels = db.Critics.Find(id); if (criticModels == null) { return(HttpNotFound()); } return(View(criticModels)); }
public async Task <ActionResult> Register(RegisterViewModel model) { if (ModelState.IsValid) { var user = new ApplicationUser { UserName = model.Email, Email = model.Email }; var result = await UserManager.CreateAsync(user, model.Password); //var role = Roles.SingleOrDefault(m => m.Name == "admin"); if (result.Succeeded) { ApplicationUser user2 = UserManager.FindByName(model.Email); UserManager.AddToRole(user2.Id, "critic"); await SignInManager.SignInAsync(user, isPersistent : false, rememberBrowser : false); CritContext db = new CritContext(); var critic = new CriticModels() { Name = model.Name, SecondName = user2.Id, Alias = model.Alias, Descritpion = model.Description }; db.Critics.Add(critic); db.SaveChanges(); // Aby uzyskać więcej informacji o sposobie włączania potwierdzania konta i resetowaniu hasła, odwiedź stronę https://go.microsoft.com/fwlink/?LinkID=320771 // Wyślij wiadomość e-mail z tym łączem // string code = await UserManager.GenerateEmailConfirmationTokenAsync(user.Id); // var callbackUrl = Url.Action("ConfirmEmail", "Account", new { userId = user.Id, code = code }, protocol: Request.Url.Scheme); // await UserManager.SendEmailAsync(user.Id, "Potwierdź konto", "Potwierdź konto, klikając <a href=\"" + callbackUrl + "\">tutaj</a>"); return(RedirectToAction("Index", "Home")); } AddErrors(result); } // Dotarcie do tego miejsca wskazuje, że wystąpił błąd, wyświetl ponownie formularz return(View(model)); }