コード例 #1
0
        private bool IsAuthorizedToSellIndustry(string industryId, IUser user)
        {
            var userAma   = new User(_database.getJObjectAsync(user.Id.ToString(), "users").Result);
            var industry  = new Industry(_database.getJObjectAsync(industryId, "industries").Result);
            var companies = _companyService.findEmployee(user).Result.ToList();

            foreach (var x in companies)
            {
                if (x.id.Equals(industryId))
                {
                    return(true);
                }
            }

            return(false);
        }
コード例 #2
0
        public async Task SetShares(string userID, string ticker, int amount)
        {
            UserShares SharesObj;

            try
            {
                SharesObj = new UserShares(await db.getJObjectAsync(userID, "shares"), true);
            }
            catch (System.NullReferenceException)
            {
                SharesObj = new UserShares(userID);
            }

            if (SharesObj.ownedShares.ContainsKey(ticker) == true)
            {
                SharesObj.ownedShares.Remove(ticker);
            }
            SharesObj.ownedShares.Add(ticker, amount);

            await db.SetJObjectAsync(db.SerializeObject <UserShares>(SharesObj), "shares");
        }
コード例 #3
0
        public async Task <Company> getCompany(string ticker)
        {
            JObject company = await __database.getJObjectAsync(ticker, "companies");

            return(new Company(company));
        }
        public JObject GetResources(string id)
        {
            JObject resources;

            try
            {
                resources = _database.getJObjectAsync(id, "resources").Result;
            }
            catch (Exception e)
            {
                resources = new Resource(id).SerializeIntoJObject();
                SetResources(resources);
            }

            return(resources);
        }