AssocOneToMany.Controllers.Manager.PlayerGetById C# (CSharp) Method

PlayerGetById() public method

public PlayerGetById ( int id ) : PlayerBase
id int
return PlayerBase
        public PlayerBase PlayerGetById(int id)
        {
            // Attempt to fetch the object
            var o = ds.Players.Find(id);

            // Return the result, or null if not found
            return (o == null) ? null : Mapper.Map<PlayerBase>(o);
        }

Usage Example

コード例 #1
0
        // GET: Players/Details/5
        public ActionResult Details(int?id)
        {
            // Attempt to get the matching object
            var o = m.PlayerGetById(id.GetValueOrDefault());

            if (o == null)
            {
                return(HttpNotFound());
            }
            else
            {
                // Pass the object to the view
                return(View(o));
            }
        }