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

  • SEARCH
  • Home
  • 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 6044287
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T06:59:40+00:00 2026-05-23T06:59:40+00:00

learning mvc and building a full blown ecommerce app. Administrators should be able to

  • 0

learning mvc and building a full blown ecommerce app.

Administrators should be able to add-edit whatever they like.

Let’s take an example Employees.

I have added an Area called “Admin”.Within admin I have Employees
In here an administrator should be able to add-edit info about employees.

Now in the user section the user should not be able to add-edit.etc..

At them moment I have 2 controllers?

  1. Areas-Admin-Controllers-EmployeeController
  2. Areas-Aboutus-Controllers-EmployeeController

It does not seem right to me.How do you handle such a code repetition?
I would like to have only one controller.How do you structure your mvc app in this case?

any example I can download?
Looking for a good examples where you can see areas working and running themes dynamically etc..

thanks for any suggestions

  • 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-05-23T06:59:41+00:00Added an answer on May 23, 2026 at 6:59 am

    You could use a single ~/Controllers/EmployeesController controller to handle the Employee resource in your application. Inside this controller actions that require administrative (or some logged in user) privileges could be decorated with the [Authorize] attribute by specifying the required roles in order to execute this action:

    public class EmployeesController: Controller
    {
        // Anyone can list employees, even anonymous users
        public ActionResult Index()
        {
            IEnumerable<Employee> employees = _repository.GetEmployees();
            return View(employees);
        }
    
        public ActionResult Show(int employeeId)
        {
            Employee employee = _repository.GetEmployee(employeeId);
            return View(employee);
        }
    
    
        // Only administrators can update employees
        [Authorize(Roles = "admin")]
        [HttpPost]
        public ActionResult Update(Employee employee)
        {
            _repository.Update(employee);
            return RedirectToAction("Index");
        }
    
        // Only administrators can delete employees
        [HttpDelete]
        [Authorize(Roles = "admin")]
        public ActionResult Destroy(int employeeId)
        {
            _repository.Delete(employeeId);
            return RedirectToAction("Index");
        }
    
        ... and some other actions following the Simply RESTful pattern: 
        http://mvccontrib.codeplex.com/wikipage?title=SimplyRestfulRouting
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm building a simple 10-page site using an MVC-like architecture. Is it worth learning
I'm learning MVC and am having trouble deciding when I should create a new
All, I'm learning MVC and using it for a business app (MVC 1.0). I'm
I'm learning ASP.NET MVC Framework, From some articles like this , it seems that
To learn ASP.net I started building a todo web app(web forms not MVC), this
I'm building a little MVC system (learning) and I have some problems with showing
I am just learning MVC and I've created a form but I would like
I'm learning Backbone.js for a new app I'm building. I need to perform an
I have a simple ASP.NET MVC 3 dummy app (just learning MVC coming from
I'm following this MVC tutorial and when I add a View for the Edit

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.