Пример #1
0
        public static TVTPerson GetPersonByNameOrCreate(ITVTDatabase database, string name, TVTDataType defaultType, bool isFakeName, TVTPersonFunction functionForNew = TVTPersonFunction.Unknown)
        {
            if (!string.IsNullOrEmpty(name))
            {
                var tempName = name.Split(',')[0];
                var person   = database.GetPersonByName(tempName);

                if (person == null)
                {
                    person = new TVTPerson();
                    person.GenerateGuid();
                    person.DataType = defaultType;
                    if (isFakeName)
                    {
                        PersonConverter.ConvertFakeFullname(person, tempName);
                    }
                    else
                    {
                        PersonConverter.ConvertFullname(person, tempName);
                    }

                    person.Functions.Add(functionForNew);
                    person.PriceMod = 1;
                    database.AddPerson(person);
                }
                return(person);
            }
            else
            {
                return(null);
            }
        }
Пример #2
0
        public static List <TVTPerson> GetPersonsByNameOrCreate(ITVTDatabase database, string names, TVTDataType defaultType, bool isFakeName, TVTPersonFunction functionForNew = TVTPersonFunction.Unknown)
        {
            var result = new List <TVTPerson>();

            if (!string.IsNullOrEmpty(names))
            {
                var array = names.Split(',');
                foreach (var aValue in array)
                {
                    var personName = aValue.Trim();

                    var person = GetPersonByNameOrCreate(database, personName, defaultType, isFakeName, functionForNew);
                    if (person != null)
                    {
                        result.Add(person);
                    }
                }
            }
            return(result);
        }