public IActionResult Create(PersonModel model) { var manager = new SourceManager(); manager.Add(model); return(RedirectToAction("Index")); }
public IActionResult Add(PersonModel person) { if (ModelState.IsValid) { SourceManager.Add(person); return(RedirectToAction("Index")); } return(View()); }
public IActionResult Add(PersonModel personModel) { if (ModelState.IsValid) { var id = SourceManager.Add(personModel); return(Content("Dodano " + id)); } return(View(personModel)); }
public IActionResult Add(PersonModel personModel) { if (ModelState.IsValid) { var id = SourceManager.Add(personModel); return(View("Succes")); } return(View(personModel)); }
public IActionResult Add(PersonModel personModel) { if (ModelState.IsValid) //walidacja { var id = SourceManager.Add(personModel); return(Redirect("Index")); } return(View(personModel)); }
public IActionResult Add(PersonModel personModel) { if (ModelState.IsValid) { SourceManager.Add(personModel); ViewBag.Title = "Add a new person | The Phone Book"; TempData["added"] = "Successfully added!"; return(View()); } return(View(personModel)); }
public ActionResult Add(PersonModel personModel) { if (ModelState.IsValid) { SourceManager sourceManager = new SourceManager(); int id = sourceManager.Add(personModel); TempData["ID"] = "Dodałeś osobę o numerze identyfikacyjnym ID: " + id; return(RedirectToAction("Index")); } return(View(personModel)); }
public IActionResult Add(PersonModel personModel) { if (ModelState.IsValid) { SourceManager.Add(personModel); TempData["mess"] = "Added"; TempData["alert"] = "alert alert-success"; return(Redirect("/Person/Index")); } return(View(personModel)); }
public IActionResult Add(PeopleModel record) { if (ModelState.IsValid) { var source = new SourceManager(); source.Add(record); return(RedirectToAction("Index")); } return(View(record)); }
public ActionResult Add(PersonModel model) { if (ModelState.IsValid) { SourceManager manager = new SourceManager(); TempData["success"] = "Dodano wpis o ID: " + manager.Add(model); return(RedirectToAction("Index", "Person")); } TempData["success"] = "Niepowodzenie podczas dodawania uzytkownika"; return(View(model)); }
public IActionResult Add(PersonModel model) { if (ModelState.IsValid) { _sourceManager.Add(model); return(RedirectToAction("Index")); } else { return(View(model)); } }
public IActionResult Add(PersonModel person) { if (ModelState.IsValid) { if (string.IsNullOrEmpty(person.Email)) { person.Email = "no email adress"; } var id = SourceManager.Add(person); TempData["Info"] = $"Dodano: {person.FirstName} {person.LastName}"; return(Redirect("Index")); } return(View(person)); }
public IActionResult Add(PersonModel personModel) { // Walidacja if (ModelState.IsValid) { // Dodanie w bazie SourceManager.Add(personModel); // Zwrócenie informacji TempData["alertclass"] = "alert alert-success my-3"; TempData["message"] = "Dodano!"; // Przekierowanie widoku return(Redirect("/Person/Index")); } // Zwrócenie widoku przy błędach return(View(personModel)); }
public IActionResult Add(PersonModel personModel) { if (!ModelState.IsValid) { return(View(personModel)); } //var manager = new SourceManager(); try { _manager.Add(personModel); } catch (Exception e) { throw; } return(RedirectToAction("Index")); }
public IActionResult Add(PersonModel person) { if (ModelState.IsValid) { int id; try { using SourceManager sourceManager = new SourceManager(); id = sourceManager.Add(person); //zapis do bazy } catch (Exception) { TempData["Error"] = "Błąd bazy danych"; TempData["Status"] = "Operacja zakończona niepowodzeniem."; return(View("DataSourceErrorPage")); // wyświetl stronę błędu } TempData["Status"] = $"Dodano wpis o Id: {id}"; ModelState.Clear(); return(View("Add")); } return(View(person)); }
public IActionResult Create(PersonModel personModel) { SourceManager.Add(personModel); return(RedirectToAction("Index")); }
public IActionResult Create(PersonModel model) { _repo.Add(model); return(RedirectToAction("Index")); }
public IActionResult ConfirmCreate(PersonModel personModel) { SourceManager.Add(personModel); return(View()); }