Exemplo n.º 1
0
 public static Planet ObjectToMessage(PlanetViewModel pvm)
 {
     var p = new Planet
     {
         Class = (int) pvm.Class,
         Category = (int) pvm.PlanetCategory,
         Id = pvm.Id,
         Name = pvm.Name,
         System = pvm.StarSystem.Id,
         Uploader = pvm.Uploader
     };
     return p;
 }
Exemplo n.º 2
0
        public static PlanetViewModel MessageToObject(Planet planet)
        {
            var pvm = new PlanetViewModel
            {
                Id = planet.Id,
                StarSystem = new StarSystemViewModel
                {
                    Id = planet.System
                },
                Class = (PlanetClass) planet.Class,
                Name = planet.Name,
                PlanetCategory = (PlanetCategory) planet.Category,
                Uploader = planet.Uploader
            };

            return pvm;
        }
Exemplo n.º 3
0
 public static List<Planet> GetPlanetsByStarSystemId(int starSystemId)
 {
     IDataReader dr = DAL.Planet.GetPlanetsByStarSystemId(starSystemId);
     var planetList = new List<Planet>();
     while (dr.Read())
     {
         var myPlanet = new Planet
         {
             Id = (int)dr["Id"],
             Category = (int)dr["Category"],
             System = (int)dr["System"],
             Name = (string)dr["Name"],
             Class = (int)dr["Class"],
             Uploader = (string) dr["Uploader"]
         };
         planetList.Add(myPlanet);
     }
     return planetList;
 }
Exemplo n.º 4
0
        public static Planet PlanetSelectRow(int id)
        {
            IDataReader dr = DAL.Planet.PlanetSelectRow(id);
            var planet = new Planet();

            if (dr.Read())
            {
                planet.Id = (int) dr["Id"];
                planet.Category = (int) dr["Category"];
                planet.System = (int) dr["System"];
                planet.Name = (string) dr["Name"];
                planet.Class = (int) dr["Class"];
                planet.Uploader = (string) dr["Uploader"];
            }
            return planet;
        }