예제 #1
0
        public void Buy(int kingdomId, int technologyId)
        {
            KingdomTechnology kt = new KingdomTechnology()
            {
                KingdomId    = kingdomId,
                TechnologyId = technologyId
            };
            KingdomTechnology old = new KingdomTechnologyDAO().GetByKingdomAndTechnology(kingdomId, technologyId);

            if (old.KingdomTechnologyId == 0)
            {
                new KingdomTechnologyDAO().Add(kt);
                Kingdom    k = new KingdomDAO().GetByUserId(CurrentUser.UserId);
                Technology t = new TechnologyDAO().GetById(technologyId);
                k.KingdomResources -= t.TechnologyCost;
                new KingdomDAO().Update(k);
            }
        }
예제 #2
0
        public void Buy(int kingdomId, int technologyId)
        {
            KingdomTechnology kt = new KingdomTechnology()
            {
                 KingdomId = kingdomId,
                 TechnologyId = technologyId
            };
            KingdomTechnology old = new KingdomTechnologyDAO().GetByKingdomAndTechnology(kingdomId, technologyId);

            if(old.KingdomTechnologyId == 0)
            {
                new KingdomTechnologyDAO().Add(kt);
                Kingdom k = new KingdomDAO().GetByUserId(CurrentUser.UserId);
                Technology t = new TechnologyDAO().GetById(technologyId);
                k.KingdomResources -= t.TechnologyCost;
                new KingdomDAO().Update(k);
            }
        }