public bool Save(ContactList contactList)
 {
     var old = ContactLists.Single(c => c.Id == contactList.Id);
     old.Name = contactList.Name;
     old.Description = contactList.Description;
     return true;
 }
        public int Add(ContactList contactList)
        {
            var errors = ValidationRunner.Run(contactList);
            if (errors != null && errors.Count > 0)
            {
                throw new ValidationException(errors);
            }
            //check if name is unique
            if (Repository.Get()
                .Count(c => c.Name.ToLower() == contactList.Name.ToLower() &&
                    c.User.UserId == contactList.User.UserId) > 0)
            {
                throw new ValidationException(
                    new List<ValidationError>
                        {
                            new ValidationError("Name", "Contact list already exists")
                        });
            }

            return Repository.Add(contactList);
        }
 public bool Save(Guid userid, ContactList contactList)
 {
     var errors = ValidationRunner.Run(contactList);
     if (errors != null && errors.Count > 0)
     {
         throw new ValidationException(errors);
     }
     //check if name is unique
     if (Repository.Get()
         .Count(c => c.Name.ToLower() == contactList.Name.ToLower() &&
             c.User.UserId == userid && c.Id != contactList.Id) > 0
             )
     {
         throw new ValidationException(
             new List<ValidationError>
                 {
                     new ValidationError("Name", "Contact list already exists")
                 });
     }
     //make sure user has permission to save
     if (Repository.Get().Count(c =>
                            c.Id == contactList.Id &&
                            c.User.UserId == userid) == 0)
         return false;
     return Repository.Save(contactList);
 }
 public int Add(ContactList contactList)
 {
     contactList.Id = AutoId;
     ContactLists.Add(contactList);
     return contactList.Id;
 }