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 9146063
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T10:40:06+00:00 2026-06-17T10:40:06+00:00

I am trying to implement a base controller, app services, repository design. I am

  • 0

I am trying to implement a base controller, app services, repository design. I am new to this level of OO design but have gotten it pretty much complete. The remaining hurdle is how to handle extending my base controller.

My Goals:

  1. have a base controller that can stand on its own…i.e. you could have a specific controller inherit from it but itself be empty and have it work.
  2. In cases where I need to extend the base controller, have the
    ability to do so in the specific controller.

Here is what I have:

Base Controller:

public class BaseControllerSingle<TRepository, TViewModelSingle> : BaseController
...
// GET: /InventoryMgmt/ManageItems/Edit/5
        public virtual ActionResult Edit( 
            int id = 0,
            string pageTitleNoun = "",
            Expression<Func<TRepository, bool>> predicate = null
        )
        {
            TViewModelSingle viewModelSingle = new TViewModelSingle();

            ViewBag.Mode = "EDIT";

            if (id == 0) //Add new company mode
            {
                viewModelSingle = _baseAppServSingle.CreateNewViewModel(CurrentUserId);
                ViewBag.Header = "Create New " + pageTitleNoun;
                ViewBag.Mode = "NEW";
                return View(viewModelSingle);
            }

            //else edit existing record mode
            viewModelSingle = _baseAppServSingle.CreateEditViewModel(id, predicate);
            ViewBag.Header = "Edit " + pageTitleNoun;

            return View(viewModelSingle);
        }

And my specific controller. Note the code in this is incorrect (specifically”ItemViewModel viewModel = actionResult(ItemViewModel);”…but trying to show what I am attempting, which is essentially to extract the view model from the action result, manipulate it further, then return it.

public class ManageItemsController : BaseController
...
// GET: /InventoryMgmt/ManageItems/Edit/5
        public ActionResult Edit(int id = 0)
        {
            ActionResult actionResult = GetBaseControllerSingle().Edit(
                "Material", 
                id, 
                x => x.Id == id && x.CompanyId == CurrentCompanyId);

            ItemViewModel viewModel = actionResult(ItemViewModel);
            if (id == 0)
            {
                viewModel = _manageItemsAppServ.CreateNewViewModel(viewModel, CurrentCompanyId);
            }

            viewModel.DDLOptions = _manageItemsAppServ.CreateFilterOptionsViewModel(CurrentCompanyId);
            return View(viewModel);
        }
  • 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-17T10:40:08+00:00Added an answer on June 17, 2026 at 10:40 am

    I have decided to re-write some of the code to remove this necessity. I think maybe it could be done with Ninject…but that’s not something I wanted to get into right now

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

Sidebar

Related Questions

Trying to implement google C2DM service. registrationIntent.putExtra(app, PendingIntent.getBroadcast(context,0,new Intent(), 0)); registrationIntent.putExtra(sender,example@gmail.com); context.startService(registrationIntent); Almost every
I am trying to implement a handy data repository or knowledge base for a
I'm trying to implement the command design pattern , but I'm stumbling accross a
I'm trying to implement Devise but new to it. When I request .../api/v1/projects.json, I
I am trying to implement logic captcha in my app. I have scaffolded simple
I'm trying to implement is_base template and I have a little problem. Why this
I'm trying to implement a force base graph layout algorithm, based on http://en.wikipedia.org/wiki/Force-based_algorithms_(graph_drawing )
Trying to implement a search similar to here .This searches properties based on city,locality,property
Trying to implement a UITableView of names similar to the built-in Contacts iPhone app
I'm trying to implement the in App purchase from within my iPhone app. To

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.