var express = require('express');
var router = express.Router();

var Country = require('../app/models/country.js');
var Province = require('../app/models/province.js');
var User = require('../app/models/user.js');

router.param(function(name, fn){
  if (fn instanceof RegExp) {
    return function(req, res, next, val){
      var captures;
      if (captures = fn.exec(String(val))) {
        req.params[name] = captures;
        next();
      } else {
        next('route');
      }
    }
  }
});

/* GET home page. */
router.get('/', function(req, res) {
  res.render('index', { title: 'Base Application' });
});

/* GET profile page */
router.get('/profile', function(req, res) {
  res.render('profile/index', { title: 'Base Application - Your Profile' });
});

/* POST profile page */
router.post('/profile', function(req, res) {
  res.render('profile/index', { title: 'Base Application - Your Profile' });
});

/* GET profile edit page */
router.get('/profile/edit', function(req, res) {
  res.render('profile/edit', { title: 'Base Application - Edit Your Profile' });
});

/* GET admin page */
router.get('/admin', function(req, res) {
  res.render('admin/index', { title: 'Base Application - Admin' });
});

/* GET admin users page */
router.get('/admin/users', function(req, res) {
  User.fetchAll({
    withRelated: ['country', 'province']
  }).then(function(users) {
    res.render('admin/users/index', { title: 'Base Application - Admin - Users', users: users.toJSON() });
  });
});

router.param('id', /^\d+$/);

/* GET admin show user page */
router.get('/admin/users/:id', function(req, res){
  User.where('id', req.params.id).fetch({
    withRelated: ['country', 'province']
  }).then(function(user) {
    res.render('admin/users/show', { title: 'Base Application - Admin - Users - Show', user: user.toJSON() });
  }).catch(function(err) {
    res.send(404);
  });
});

module.exports = router;

@@ -1879,16 +1879,350 @@
 );%0A%7D);%0A%0A
+router.get('/admin/users/edit/:id', function(req, res)%7B%0A  User.where('id', req.params.id).fetch(%7B%0A    withRelated: %5B'country', 'province'%5D%0A  %7D).then(function(user) %7B%0A    res.render('admin/users/edit', %7B title: 'Base Application - Admin - Users - Show', user: user.toJSON() %7D);%0A  %7D).catch(function(err) %7B%0A    res.send(404);%0A  %7D);%0A%7D);%0A%0A
 module.e

Edit user route