Ejemplo n.º 1
0
        public static ContactModel ConvertToContactModel(this Contact contact)
        {
            var model =  new ContactModel
            {

                ReadyToBuyScore = contact.Score,
                ReadyToSell = contact.ReadyToSell != null ? contact.ReadyToSell.Name : String.Empty,
                Name = contact.Name,
                CreateDate = contact.CreateDate,
                Email = contact.Email,
                Id = contact.Id, 
                ContactIp = contact.Ip,
                ContactLink = contact.Link,
                Status = contact.Status != null ? contact.Status.Name : String.Empty,
                AgeDirection = contact.Age != null ? contact.Age.Name : String.Empty,
                Comment = contact.Comment,
                ContactType = contact.Type != null ? contact.Type.Name : String.Empty,
                Gender = contact.Gender.ToString(),
            //    //Telephones = contact.Telephones.
            };
            if (contact.BirthDate.HasValue)
            {
                model.BirthDate = contact.BirthDate.Value;
            }
            return model;
        }
Ejemplo n.º 2
0
 public ActionResult Add(ContactModel contact)
 {
     var dbContact = _contactBusinessLogic.GetById(contact.Id);
     if (dbContact == null)
     {
         dbContact = new Contact();
     }
     dbContact.Age = _contactBusinessLogic.GetAllAges().First(x => x.Id == contact.AgeDirectionId);
     dbContact.BirthDate = contact.BirthDate;
     dbContact.Comment = contact.Comment;
     dbContact.CreateDate = DateTime.Now;
     dbContact.Email = contact.Email;
     dbContact.Ip = contact.ContactIp;
     dbContact.Gender = (GenderEnum)Enum.Parse(typeof(GenderEnum), contact.Gender);
     dbContact.Link = contact.ContactLink;
     dbContact.IsNameChecked = true;
     dbContact.ReadyToBuyScore = contact.ReadyToBuyScore;
     dbContact.ReadyToSell = _contactBusinessLogic.GetAllSellStatuses().First(x => x.Id == contact.ReadyToSellId);
     //dbContact.Telephones = contact.Telephones.Split(';').ToList();
     dbContact.Status = _contactBusinessLogic.GetAllStatuses().First(x => x.Id == contact.StatusId);
     dbContact.Type = _contactBusinessLogic.GetAllTypes().First(x => x.Id == contact.ContactTypeId);
     dbContact.Name = contact.Name;
     _contactBusinessLogic.Add(dbContact);
     return RedirectToAction("List");
 }