Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8001181
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T16:01:23+00:00 2026-06-04T16:01:23+00:00

I have been developing my first large (for me) MVC project for a couple

  • 0

I have been developing my first large (for me) MVC project for a couple of months now and things are getting exceedingly difficult to navigate.

I have been slacking off on refactoring and am seeking modern examples of ‘best practices’ as far as keeping your controller thin and moving all of that data to your models.

I read this article that discusses things in detail, but does not provide an example project.

Most ‘best practices’ threads posted here tend to link to MVC Music Store or the Nerd Dinner project, but at the same time the comments tend to say they are more ‘beginner’s guides’ rather than examples of ‘best practices.’

Does anyone know of any up-to-date open-source MVC projects that demonstrate proper development structure?

note: A typical problem that I’d like to learn to resolve: My controllers are very long and full of code that drives the website – I need to move this code off into methods that are merely referenced by the controller. Where do I throw all of these methods?

Here is a an sample of my code from a controller as suggested by a comment on one of the replies. How would I move some of this information over to my ViewModel? (I have included the ViewModel below):

Controller:

public ActionResult AttendanceView(int id)
{
    //
    // Generates list of Attendances specifically for current Course
    var attendanceItems = db.Attendance.Where(s => s.CourseID == id);
    List<Attendance> attendanceItemsList = attendanceItems.ToList();
    // End of generating list of Attendances

    //
    // Generates list of Students in alphabetical order sorted by LastName
    var student = attendanceItemsList.Select(a => a.Student).Distinct().OrderBy(s => s.LastName);
    List<Student> StudentList = student.ToList();
    // End of generating list of Students


    //
    // Generates list of AttendingDays specifically for current Course
    Course course = db.Courses.FirstOrDefault(p => p.CourseID == id);
    List<int> attDayList = new List<int>();
    for (int i = 0; i < course.AttendingDays; i++)
    {
        attDayList.Add(i + 1);
    };
    // End of generating list of AttendingDays

    AttendanceReportViewModel model = new AttendanceReportViewModel
    {
        AttendanceDays = attDayList,
        Students = StudentList,
        Attendances = attendanceItemsList,
        courseId = id
    };
    return View(model);
}

ViewModel:

namespace MyApp.ViewModels
{
    public class AttendanceReportViewModel
    {
        public List<int> AttendanceDays { get; set; }

        public List<Student> Students { get; set; }

        public List<Attendance> Attendances { get; set; }

        public int courseId { get; set; }

        public string IsPresent(Student student, int attendanceDay)
        {
            return Attendances.Single(a => a.StudentID == student.StudentID && a.AttendanceDay == attendanceDay).Present ? MyAppResource.Present_Text : MyAppResource.Absent_Text;
        }
    }
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T16:01:25+00:00Added an answer on June 4, 2026 at 4:01 pm

    What you’re basically looking for is a layered architecture. For example the Service Layer pattern requires you to define a lot of the logic in the service layer instead of in your controllers.

    There are examples of this, one of them being Silk from the Pattern & Practices team at Microsoft: http://silk.codeplex.com/

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have been developing a library that is getting pretty large, and now I
I have been developing an asp.net mvc application where i need to make large
I have been developing my first TCP/Socket based application with Apache Mina, it looks
I have been developing a project and in this project i have designed my
I have been developing an app in FatFree framework and now I am trying
I have been developing my first mobile site with jQuery Mobile and you can
This is my first site built in Silverstripe, I have been developing the site
I have been developing a new online game for the past year now. The
I have been developing Android application since 3 to 4 months. I am naive,
I have been developing (for the last 3 hours) a small project I'm doing

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.