Example #1
0
        public IActionResult Create(PersonModel model)
        {
            var manager = new SourceManager();

            manager.Add(model);

            return(RedirectToAction("Index"));
        }
Example #2
0
 public IActionResult Add(PersonModel person)
 {
     if (ModelState.IsValid)
     {
         SourceManager.Add(person);
         return(RedirectToAction("Index"));
     }
     return(View());
 }
Example #3
0
 public IActionResult Add(PersonModel personModel)
 {
     if (ModelState.IsValid)
     {
         var id = SourceManager.Add(personModel);
         return(Content("Dodano " + id));
     }
     return(View(personModel));
 }
Example #4
0
 public IActionResult Add(PersonModel personModel)
 {
     if (ModelState.IsValid)
     {
         var id = SourceManager.Add(personModel);
         return(View("Succes"));
     }
     return(View(personModel));
 }
Example #5
0
        public IActionResult Add(PersonModel personModel)
        {
            if (ModelState.IsValid)                //walidacja
            {
                var id = SourceManager.Add(personModel);

                return(Redirect("Index"));
            }
            return(View(personModel));
        }
Example #6
0
 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));
 }
Example #8
0
 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));
 }
Example #9
0
        public IActionResult Add(PeopleModel record)
        {
            if (ModelState.IsValid)
            {
                var source = new SourceManager();
                source.Add(record);

                return(RedirectToAction("Index"));
            }

            return(View(record));
        }
Example #10
0
        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));
        }
Example #11
0
        public IActionResult Add(PersonModel model)
        {
            if (ModelState.IsValid)
            {
                _sourceManager.Add(model);

                return(RedirectToAction("Index"));
            }
            else
            {
                return(View(model));
            }
        }
Example #12
0
 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));
 }
Example #13
0
 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"));
        }
Example #15
0
 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));
 }
Example #16
0
 public IActionResult Create(PersonModel personModel)
 {
     SourceManager.Add(personModel);
     return(RedirectToAction("Index"));
 }
Example #17
0
        public IActionResult Create(PersonModel model)
        {
            _repo.Add(model);

            return(RedirectToAction("Index"));
        }
Example #18
0
        public IActionResult ConfirmCreate(PersonModel personModel)
        {
            SourceManager.Add(personModel);

            return(View());
        }