This question is related to my ASP.NET MVC 2 development, but it could apply to any MVC environment and a question of where the logic should go.
So let's say I have a controller that takes an online payment such as a shopping cart application. And I have the method that accepts the customers' credit card information:
public class CartController : Controller
CartRepository cartRepository = new CartRepository()
[HttpPost]
public ActionResult Payment(PaymentViewModel rec)
{
if(!ModelState.IsValid)
{
return View(rec);
}
// process payment here
return RedirectToAction("Receipt");
}
At the comment process payment here
should the payment processing be handled:
- In the controller?
- By the repository?
- Someplace else?