HomeController.cs 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Web;
  5. using System.Web.Mvc;
  6. using GreenTree.Nachtragsmanagement.Web.Framework;
  7. using GreenTree.Nachtragsmanagement.Web.Models.User;
  8. namespace GreenTree.Nachtragsmanagement.Web.Controllers
  9. {
  10. public class HomeController : Controller
  11. {
  12. // GET: Home
  13. public ActionResult Index()
  14. {
  15. return View("~/Views/Home/Index.cshtml");
  16. }
  17. [HttpPost]
  18. public ActionResult Index(UserModel model)
  19. {
  20. var userSet = ApplicationContext.Current.DbContextService.GetDbSet<Core.Domain.User.User>();
  21. var dbContext = ApplicationContext.Current.DbContextService.GetDbContext();
  22. var newUser = new Core.Domain.User.User
  23. {
  24. CustomId = model.CustomId,
  25. Forename = model.Forename,
  26. Lastname = model.Lastname,
  27. MailAddress = model.MailAddress
  28. };
  29. userSet.Add(newUser);
  30. dbContext.SaveChanges();
  31. return View("~/Views/Home/Index.cshtml");
  32. }
  33. }
  34. }