My first try of MVC. Am trying to implement a simple example. Inspiration from here. Have I got this pattern (yet!)?
View: "Hey, controller, the user just told me he wants the first person"
Controller: "Hmm, having checked his credentials, he is allowed to do that... Hey, model, I want you to get me the first person"
Model: "First person... got it. Back to you, Controller."
Controller: "Here, I'll collect the new set of data. Back to you, view."
View: "Cool, I'll show the first person to the user now."
View:
namespace WinFormMVC { public partial class Form1 : Form { controller cont = new controller(); public Form1() { InitializeComponent(); } private void button1_Click(object sender, EventArgs e) { textBox1.Text = cont.checkPermissionsAndGetFirstPerson(); } } } Controller:
public class controller { public string checkPermissionsAndGetFirstPerson() { string returnValue = ""; if (checkPermissions()) { model m = new model(); returnValue = m.getFirstPerson(); } return returnValue; } public bool checkPermissions() { return true; } } Model:
public class model { public string getFirstPerson() { return "Bill Smith"; } }