Note that there are some explanatory texts on larger screens.

plurals
  1. POASP.NET MVC2: Help building admin site and routing
    primarykey
    data
    text
    <p>I'm building a web app (front-end and admin section). There are 4 main record types (books, cars, houses, deals). The user can do query and see the detail of each record type, the admin can do query as well and in addition can edit and delete.</p> <p><b>Front end</b></p> <ul> <li>controller: each record type has the following actions</li> </ul> <p><code> //<br /> // GET: /{recordType}/Index<br /> //<br /> // GET: /{recordType}/Search<br /> </code></p> <ul> <li>routing:</li> </ul> <p><code> routes.MapRoute("BookDetail", "Books/{Id}", new { controller = "Books", action = "Details", id = Optional }, new { Id = @"\d+" } );<br> routes.MapRoute("CarDetail", "Cars/{Id}", new { controller = "Cars", action = "Details", id = Optional }, new { Id = @"\d+" } );<br> [...] </code></p> <ul> <li>views: there is a folder for each record types with two pages Index.aspx (search form and result grid) and Details.aspx.</li> </ul> <p><b>Admin</b></p> <ul> <li>controller: there is a main action the renders an empty view each record type has the following actions</li> </ul> <p><code> [HttpGet] public virtual ActionResult SearchRecord(RecordTypes? recordType){return View(GetViewNameFromRecordType(recordType));}<br /> //<br /> // GET: /Admin/{recordType}/Create<br /> //<br /> // POST: /Admin/{recordType}/Create<br /> //<br /> // GET: /Admin/{recordType}/Search<br /> //<br /> // POST: /Admin/{recordType}/Search<br /> //<br /> // GET: /Admin/{recordType}/Edit/1<br /> //<br /> // POST: /Admin/{recordType}/Save/1<br /> //<br /> // GET: /Admin/{recordType}/Delete/1<br /> //<br /> // POST: /Admin/{recordType}/Delete/1<br /> </code></p> <ul> <li>routing: I'm struggling because I would like to reflect my controller logic but I don't want to create a huge amount of routes.</li> </ul> <p><code> routes.MapRoute("BookDetail", "Admin/Books/Save/{Id}", new { controller = "Books", action = "SaveBook", recordtype = "Book" } ); routes.MapRoute("BookDetail", "Admin/Books/Create/{Id}", new { controller = "Books", action = "CreateBook", recordtype = "Book" } ); [...] </code></p> <ul> <li>views: there is an Admin folder with all the pages EditBook.aspx, SearchBook.aspx but actually I don't like this.</li> </ul> <p>==</p> <p>What do you think? How can I avoid to add a lot of routes for each record type?</p> <p>Thanks!</p> <p>Lorenzo.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload