Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- *** Models/MonthEnum.cs ***
- public enum MonthEnum : int
- {
- January = 0,
- February,
- March,
- April,
- May,
- June,
- July,
- August,
- September,
- October,
- November,
- December
- }
- *** Models/MonthEnum.cs ***
- [HttpPost]
- public IActionResult Index(PersonalData personalData)
- {
- if (!ModelState.IsValid)
- return View(personalData);
- var monthOfBirth = (MonthEnum)personalData.DateOfBirth.Month;
- var shortMonth = monthOfBirth.ToString().Substring(0, 3);
- TempData["personName"] = personalData.FirstName + " " + personalData.LastName;
- TempData["personBirthMonth"] = shortMonth;
- return RedirectToAction("Success");
- }
- *** Success.cshtml ***
- @{
- var personName = TempData["personName"] as string;
- var personBirthMonth = TempData["personBirthMonth"] as string;
- }
- <h1>You have succesfully submitted the data</h1>
- <hr />
- <div class="text-primary">Name: @personName</div>
- <div class="text-primary">Month of birth: @personBirthMonth</div>
- <hr />
- <a asp-controller="Home" asp-action="Index" class="btn-sm btn-primary">Back</a>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement