Exemplo n.º 1
0
        public static Contact ConvertToDbContact(this ContactModel model)
        {
            var factory = new DatabaseFactory();
            var contactBusinessLogic = new ContactBusinessLogic(new ContactRepository(factory), new DictionaryBusinessLogic<ContactType>(new DictionaryRepository<ContactType>(factory)),
                new DictionaryBusinessLogic<ContactStatus>(new DictionaryRepository<ContactStatus>(factory)), new DictionaryBusinessLogic<AgeDirection>(new DictionaryRepository<AgeDirection>(factory)),
                new DictionaryBusinessLogic<ReadyToSellState>(new DictionaryRepository<ReadyToSellState>(factory)));

            var dbContact = contactBusinessLogic.GetById(model.Id);
            if (dbContact == null)
            {
                dbContact = new Contact();
            }
            dbContact.Age = contactBusinessLogic.GetAllAges().First(x => x.Id == model.AgeDirectionId);
            dbContact.BirthDate = model.BirthDate;
            dbContact.Comment = model.Comment;
            dbContact.CreateDate = DateTime.Now;
            dbContact.Email = model.Email;
            dbContact.Ip = model.ContactIp;
            dbContact.Gender = (GenderEnum)Enum.Parse(typeof(GenderEnum), model.Gender);
            dbContact.Link = model.ContactLink;
            dbContact.IsNameChecked = true;
            dbContact.ReadyToBuyScore = model.ReadyToBuyScore;
            dbContact.ReadyToSell = contactBusinessLogic.GetAllSellStatuses().First(x => x.Id == model.ReadyToSellId);
            //dbContact.Telephones = contact.Telephones.Split(';').ToList();
            dbContact.Status = contactBusinessLogic.GetAllStatuses().First(x => x.Id == model.StatusId);
            dbContact.Type = contactBusinessLogic.GetAllTypes().First(x => x.Id == model.ContactTypeId);
            dbContact.Name = model.Name;
            //dbContact.Id = model.Id;
            return dbContact;
        }
Exemplo n.º 2
0
 public CounterService()
 {
     var factory = new DatabaseFactory();
     _activityBusinessLogic = new ActivityBusinessLogic(new ActivityRepository(factory), new TagBusinessLogic(new TagRepository(factory))
         , new DictionaryBusinessLogic<ActivityType>(new DictionaryRepository<ActivityType>(factory)) );
     _contactBusinessLogic = new ContactBusinessLogic(new ContactRepository(factory), new DictionaryBusinessLogic<ContactType>(new DictionaryRepository<ContactType>(factory)),
         new DictionaryBusinessLogic<ContactStatus>(new DictionaryRepository<ContactStatus>(factory)), new DictionaryBusinessLogic<AgeDirection>(new DictionaryRepository<AgeDirection>(factory)),
         new DictionaryBusinessLogic<ReadyToSellState>(new DictionaryRepository<ReadyToSellState>(factory)));
 }