public void SaveProduct(Human human)
 {
     if (human.HumanID != -1)
     {
         context.Humans.Add(human);
     }
 }
Пример #2
0
 private void PrepareHuman()
 {
     foreach (Man item in manlist)
     {
         if (!item.Private)
         {
             Human h = new Human();
             Human.Settings = "search" + opcode.ToString();
             h.Additional = new List<KeyValuePair<string, string>>();
             h.Tags = new Dictionary<string, double>();
             h.Links = new Dictionary<string, string>();
             h.HumanID = counter;
             h.Name = item.name;
             if (item.city[0] == null)
             {
                 if (item.city[1] != null)
                 {
                     if (fake.Location != null)
                     {
                         if (item.city[1].ToLower() == fake.Location.ToLower())
                             h.Location = item.city[1];
                         else continue;
                     }
                     else
                     {
                         h.Location = item.city[1];
                     }
                 }
                 else h.Location = "Неизвестный";
             }
             else if (item.city[0] != null)
             {
                 if (fake.Location != null)
                 {
                     if (item.city[0].ToLower() == fake.Location.ToLower()) 
                         h.Location = item.city[0];
                     else continue;
                 }
                 else
                 {
                     h.Location = item.city[0];
                 }
             }
             if (h.Location.Length > 20)
             {
                 h.Location.Substring(0, 15);
                 h.Location += "...";
             }
             if (item.age != null) h.Age = item.age;
             else if (fake.Age != null && fake.Age != 0) h.Age = fake.Age.ToString();
             if (item.photo != null) h.Image = item.photo;
             //другая информация
             List<string> list = new List<string>();
             foreach (string link in item.links)
             {
                 if (link != null && link.IndexOfAny("абвгдеёжзийклмнопрстуфхцчшщъыьэюя".ToCharArray()) == -1 && !h.Links.ContainsKey(link))
                     h.Links.Add(link, GetWebsiteName(link));
             }
             if (item.tags.Count > 0)
             {
                 foreach (var word in item.tags)
                 {
                     h.Tags.Add(word.Key, word.Value);
                 }
             }
             if (item.birthday != null)
             {
                 h.Additional.Add(new KeyValuePair<string, string>("День рождения: ", item.birthday));
             }
             if (item.nicks.Count > 0)
             {
                 foreach (string nick in item.nicks)
                 {
                     if (nick != null)
                         h.Additional.Add(new KeyValuePair<string, string>("Используемый ник: ", nick));
                 }
             }
             if (item.family != null)
             {
                 h.Additional.Add(new KeyValuePair<string, string>("Семейное положение: ", item.family));
             }
             if (item.phone.Length > 0)
             {
                 foreach (string phone in item.phone)
                 {
                     if (phone != null)
                         h.Additional.Add(new KeyValuePair<string, string>("Способ связи: ", phone));
                 }
             }
             if (item.edc.Length > 0)
             {
                 foreach (Education edu in item.edc)
                 {
                     if (edu != null)
                     {
                         h.Additional.Add(new KeyValuePair<string, string>("ВУЗ: ", edu.univer));
                         h.Additional.Add(new KeyValuePair<string, string>("Факультет: ", edu.faculty));
                         h.Additional.Add(new KeyValuePair<string, string>("Кафедра: ", edu.cafedra));
                         h.Additional.Add(new KeyValuePair<string, string>("Форма обучения: ", edu.form));
                         h.Additional.Add(new KeyValuePair<string, string>("Статус: ", edu.state));
                     }
                 }
             }
             if (item.jobs.Count > 0)
             {
                 foreach (string job in item.jobs)
                 {
                     if (job != null)
                         h.Additional.Add(new KeyValuePair<string, string>("Место работы: ", job));
                 }
             }
             //сохранение в репозиторий и 
             //удаленное заполнение уже с репозитория
             rep.SaveProduct(h);
             counter++;
         }
     }
 }