public IHttpActionResult GetResearchTypes(int UserID)
 {
     try
     {
         return(Ok(ResearchDAL.GetResearchTypes(UserID)));
     }
     catch (Exception e)
     {
         return(InternalServerError(e));
     }
 }
Пример #2
0
        public static AllbuildQues GetBuildingQueue(int?PlanetID, int?UserID)
        {
            AllbuildQues       allq             = new AllbuildQues();
            List <BuildingQue> buildingQues     = PlanetDAL.GetBuildingQueue(UserID);
            DateTime           UTC              = DateTime.UtcNow;
            List <BuildingQue> BuildingsQueLeft = new List <BuildingQue>();
            List <BuildingQue> ResearchQueLeft  = new List <BuildingQue>();
            List <BuildingQue> ShipQueLeft      = new List <BuildingQue>();

            foreach (BuildingQue item in buildingQues.FindAll(x => x.Type == 1))
            {
                if (item.CompletetionDate < UTC)
                {
                    PlanetDAL.InsertUpdatePlanetBuilding(item.PlanetID, item.BuildingID);
                    PlanetDAL.RemoveBuildingQueue(item.BuildQueID);
                }
                else
                {
                    if (item.PlanetID == PlanetID)
                    {
                        BuildingsQueLeft.Add(item);
                    }
                }
            }
            foreach (BuildingQue item in buildingQues.FindAll(x => x.Type == 2))
            {
                if (item.CompletetionDate < UTC)
                {
                    ResearchDAL.InsertUpdatePlayerTech(item.UserID, item.BuildingID);
                    PlanetDAL.RemoveBuildingQueue(item.BuildQueID);
                }
                else
                {
                    if (item.PlanetID == PlanetID)
                    {
                        ResearchQueLeft.Add(item);
                    }
                }
            }
            foreach (BuildingQue item in buildingQues.FindAll(x => x.Type == 3))
            {
                if (item.CompletetionDate < UTC)
                {
                    ShipBLL.InsertUpdatePlayerShip(item);
                    PlanetDAL.RemoveBuildingQueue(item.BuildQueID);
                }
                else
                {
                    if (item.PlanetID == PlanetID)
                    {
                        ShipQueLeft.Add(item);
                    }
                }
            }

            allq.buildingQue = BuildingsQueLeft.OrderBy(x => x.CompletetionDate).ToList();
            allq.researchQue = ResearchQueLeft.OrderBy(x => x.CompletetionDate).ToList();
            allq.shipQue     = ShipQueLeft.OrderBy(x => x.CompletetionDate).ToList();

            return(allq);
        }