// GET: Employees/DetailsByUserName/{username}
 // The purpose of this method is to support a username lookup,
 // but as you can see, it simply redirects with the user identifier
 // to the next method
 public ActionResult DetailsByUserName(string username)
 {
     // Determine whether we can continue, non-null username
     if (username != null)
     {
         // Attempt to fetch the object
         int? userId = m.GetEmployeeIdForUserName(username);
         if (userId != null)
         {
             // If found, redirect to the Details method, specifying the Employee Id
             return RedirectToAction("Details", new { id = userId });
         }
     }
     throw new NotImplementedException();
 }
Exemplo n.º 2
0
        // GET: Notes/Create/{id}
        public ActionResult Create()
        {
            int?emp_id = m.GetEmployeeIdForUserName(User.Identity.Name);

            // Validate the user name
            if (!emp_id.HasValue)
            {  // If validation fails, exit
                return(HttpNotFound());
            }
            else
            { // Otherwise, continue...
                // Create and configure an 'add form'
                var addForm = new NoteAddForm();
                addForm.EmployeeId = (int)emp_id;
                return(View(addForm));
            }
        }
        // GET: Employees/DetailsByUserName/{username}
        // The purpose of this method is to support a username lookup,
        // but as you can see, it simply redirects with the user identifier
        // to the next method
        public ActionResult DetailsByUserName(string username)
        {
            // Determine whether we can continue, non-null username

            if (username == null)
            {
                return(RedirectToAction("index"));
            }
            else
            {
                // Attempt to fetch the object
                var identifier = m.GetEmployeeIdForUserName(username);

                if (identifier == null)
                {
                    return(RedirectToAction("index"));
                }
                else
                {
                    // If found, redirect to the Details method, specifying the Employee Id
                    return(RedirectToAction("details", new { id = identifier }));
                }
            }
        }