코드 3-12 ASP.NET 코어로 만든 배송지 입력 폼 처리 코드
[HttpPost]
public IActionResult Submit(ShipmentAddress form) {
if (!ModelState.IsValid) {
return RedirectToAction("Index", "ShippingForm", form); } var validationResult = service.ValidateShippingForm(form); if (validationResult != ShippingFormValidationResult.Valid) { return RedirectToAction("Index", "ShippingForm", form); } bool success = service.SaveShippingInfo(form); if (!success) { ModelState.AddModelError("", "Problem occurred while " + "saving your information, please try again"); return RedirectToAction("Index", "ShipingForm", form);
→ 중복된 종료 지점
}
return RedirectToAction("Index", "BillingForm"); → 행복한 경로
}