c# - Organizing actions into controllers -


alright... need list uploads, downloads , requests made. need list uploads, downloads , requests specific user. i'm not sure place actions in order make logical. actions returning data json.

  • a upload added when user invokes post: index(file) in uploadscontroller.
  • a download added when user invokes get: files(filename) in uploadscontroller.
  • a request added when user invokes actionresult marked logattribute.

what controllers looks like:

userscontroller

  • get: list
  • get: create
  • post: create(viewmodel)
  • post: delete(userid)
  • get: signin
  • post: signin(username, pwd)
  • post: signout

uploadscontroller

  • get: index
  • post: index(file)
  • get: files(filename)

approach 1:

create 2 new controllers, downloadscontroller , requestscontroller. in both these controllers, , uploadscontroller create following actions:

  • get: listall
  • get: listfor(userid)

approach 2:

create new controller, statscontroller has following actions:

  • get: listalluploads
  • get: listuploadsfor(userid)
  • get: listalldownloads
  • get: listuploadsfor(userid)
  • get: listallrequests
  • get: listrequestsfor(userid)

as mentioned earlier, i'm not sure (if any) of 2 approaches makes sense. shed light over, "best"?

controllers should group functionally related action methods - @ least, such take. have several thousand line class had unrelated methods in did unique things? if not, don't think controller different; class methods after all. i'd opt either approach - both me. depends on prefer. might go more granular , have uploadscontroller downloadscontroller , requestscontroller. these controller names isolate views unique folders, more human-friendly other developers well.


Comments

Popular posts from this blog

php - Calling a template part from a post -

Firefox SVG shape not printing when it has stroke -

How to mention the localhost in android -