Ejemplo n.º 1
0
        /// <summary>
        /// Return existing <see cref="Residence"/> by supplied owner name, if not locally cached it will be retrieved from the database.
        /// </summary>
        public static async Task <Residence> GetResidence(string name)
        {
            if (ownerCache.TryGetValue(name, out ulong residenceId))
            {
                return(GetResidence(residenceId));
            }

            ResidenceModel model = await CharacterDatabase.GetResidence(name);

            if (model == null)
            {
                return(null);
            }

            var residence = new Residence(model);

            residences.TryAdd(residence.Id, residence);
            ownerCache.TryAdd(name, residence.Id);
            return(residence);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Return existing <see cref="Residence"/> by supplied residence id, if not locally cached it will be retrieved from the database.
        /// </summary>
        public async Task <Residence> GetResidence(ulong residenceId)
        {
            Residence residence = GetCachedResidence(residenceId);

            if (residence != null)
            {
                return(residence);
            }

            ResidenceModel model = await CharacterDatabase.GetResidence(residenceId);

            if (model == null)
            {
                return(null);
            }

            residence = new Residence(model);
            residences.TryAdd(residence.Id, residence);
            ownerCache.TryAdd(model.Owner.Name, residence.Id);
            return(residence);
        }