示例#1
0
        public static List <ShipHull> GetShipHulls(string keelDesignator)
        {
            using (CodeFighterContext db = new CodeFighterContext())
            {
                List <ShipHull> result = new List <ShipHull>();

                IQueryable <ShipHullData> hullData = db.ShipHullData
                                                     .Include("PartCounts").Include("PartCounts.PartCountData");
                if (!string.IsNullOrEmpty(keelDesignator))
                {
                    hullData = hullData.Where(x => x.HullSize.Equals(keelDesignator));
                }
                foreach (ShipHullData shd in hullData)
                {
                    ShipHull hull = new ShipHull();
                    hull.Id             = shd.Id;
                    hull.ClassName      = shd.ClassName;
                    hull.Hitpoints      = new StatWithMax(shd.MaxHitPoints);
                    hull.Size           = Keel.ByDesignator(shd.HullSize);
                    hull.MaxParts       = Convert.ToInt32(Math.Round(hull.Size.MaxAddedMass / hull.Size.Classification.PartWeight));
                    hull.MaxPartsByType = new List <PartCount>();
                    foreach (ShipHullPartCountData shpcd in shd.PartCounts)
                    {
                        PartCount pc = new PartCount();
                        pc.PartType        = Type.GetType(shpcd.PartCountData.PartType);
                        pc.ActionMechanism = shpcd.PartCountData.ActionMechanism;
                        pc.CountOfParts    = shpcd.PartCountData.CountOfParts;
                        hull.MaxPartsByType.Add(pc);
                    }
                    result.Add(hull);
                }

                return(result);
            }
        }
示例#2
0
        public ActionResult GetKeels()
        {
            List <Keel> keels = Keel.All();

            return(new JsonResult()
            {
                Data = keels
            });
        }
示例#3
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                List <Keel> allKeels = Keel.All();
                List <Tuple <string, string> > keelSource = new List <Tuple <string, string> >();
                keelSource.Add(new Tuple <string, string>("All", ""));
                foreach (Keel k in allKeels)
                {
                    keelSource.Add(new Tuple <string, string>(k.Name, k.Designator));
                }

                ddlKeel.DataSource     = keelSource;
                ddlKeel.DataTextField  = "Item1";
                ddlKeel.DataValueField = "Item2";
                ddlKeel.DataBind();

                List <ShipHull> hulls = DataFactory.GetShipHulls(string.Empty);
                gvHulls.DataSource = hulls;
                gvHulls.DataBind();
            }
        }