Click here to Skip to main content
12,699,215 members (24,901 online)
Click here to Skip to main content

Tagged as

Stats

178.3K views
2.6K downloads
123 bookmarked
Posted

Differences between MVC and MVP for Beginners

, 23 Nov 2011 CPOL
This article aims to describe MVC and MVP in simple terms
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace MVPTester
{
    interface ICommands
    {
         void Execute();
         Model CurrentModel { get; set; }
    }


    public class SaveCommand : ICommands
    {
        string _username = "";
        string _email = "";
        //Model _model;
        public Model CurrentModel { get; set; }
        //public Model CurrentModel
        //{
        //    get
        //    {
        //        return _model;
        //    }

        //    set
        //    {
        //        _model = value;
        //    }
        //}
      

        public SaveCommand(string username, string email)
        {
            _username = username;
            _email = email;
        }

        public void Execute()
        {

            CurrentModel.Save(_username,_email);
        }

    }




    class Presenter
    {
        IStudentModel _model;
        IStudentView _view;

        public Presenter(IStudentModel model, IStudentView view)
        {
            _model = model;
            _view = view;
           
        }
        public void Save(string username, string email)
        {
            
            _model.Save(username, email);
        }

        public void Execute(ICommands command)
        {
            command.CurrentModel = (Model)_model;
            command.Execute();
        }

        public bool IsEntryExisting(string username)
        {
            return _model.IsEntryExisting(username);
        
        }
    }
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author

John T.Emmatty
Software Developer (Senior) WEPA
India India
My aim is to write articles in plain English without any convoluted or periphrastic statements.

You may also be interested in...

Pro
| Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.170118.1 | Last Updated 23 Nov 2011
Article Copyright 2011 by John T.Emmatty
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid