View using Controller in Another App (ASP.Net)

Associate
Joined
25 Feb 2007
Posts
905
Location
Midlands
Hi,

I'm not really sure how to explain what I'm after, so bear with me!

Essentially, I have an MVC web app using Entity Framework. Let's call this System A

I need to provide part of the functionality of System A (the Create aspect) within System B - it needs to look like System B (so using System B's view layout) but keep all of the additional functionality that System A provides on Creation.

How could I do this?

Let me know if I need to provide more info!

Ta,
 
Just looking in to adding a Web API now - is it possible to have a method in the web api that essentially calls the method of the existing controller and just passes it data? My existing method already contains a lot code and I think it would be easier to just call this rather than recreate the functionality?
 
Sorry I probably made the method sound more complex than it actually was!

It's mainly just checking the Model State and then adding the item to the database!

However I do also queue some email sending methods via Hangfire (not sure if you're aware of it?) - these methods live in my controller class - would best practice be to move these elsewhere?
 
Creating a scaffolded Entity Framework controller does this by default though? Are you saying that this is wrong?

So this is the default code in my scaffolded controller:
Code:
[HttpPost]
[ValidateAntiForgeryToken]
public ActionResult Create([Bind(Include = "ID,ItemName,CreatedDate")] Item item)
{
     if (ModelState.IsValid)
     {
          db.Items.Add(item);
          db.SaveChanges();

          return RedirectToAction("Index");
     }

     return View(item);
}
 
Back
Top Bottom