예제 #1
0
 /// <summary>
 /// Gets all contacts from the Azure storage with the specified Id.
 /// </summary>
 /// <param name="blobId">
 /// The blob Id.
 /// </param>
 /// <returns>
 /// a list of <see cref="StdContact"/>
 /// </returns>
 public ContactListContainer GetAll(string blobId)
 {
     try
     {
         // this can be replaced by any class inheriting from StdClient
         var client      = new BlobStorageStdClient();
         var stdContacts = new ContactListContainer
         {
             ContactList = client.GetAll(blobId ?? "default").ToStdContacts()
         };
         return(stdContacts);
     }
     catch (Exception ex)
     {
         return(new ContactListContainer
         {
             ContactList = new List <StdContact>(),
             Messages = new List <TechnicalMessage> {
                 new TechnicalMessage {
                     Message = ex.Message
                 }
             }
         });
     }
 }
예제 #2
0
        /// <summary>
        /// Writes a list of contacts to the Azure storage
        /// </summary>
        /// <param name="elements">
        /// The elements to write to the storage.
        /// </param>
        /// <param name="blobId">
        /// The contact blob id.
        /// </param>
        /// <param name="skipIfExisting">
        /// This parameter is not used at the moment.
        /// </param>
        /// <returns>
        /// True if the operation was successful
        /// </returns>
        public BooleanResultContainer WriteFullList(ContactListContainer elements, string blobId, bool skipIfExisting)
        {
            try
            {
                // this can be replaced by any class inheriting from StdClient
                var client = new BlobStorageStdClient();
                client.WriteRange(elements.ContactList.ToStdElements(), blobId ?? "default");
            }
            catch (Exception ex)
            {
                return(new BooleanResultContainer
                {
                    Result = false,
                    Messages = new List <TechnicalMessage> {
                        new TechnicalMessage {
                            Message = ex.Message
                        }
                    }
                });
            }

            return(new BooleanResultContainer {
                Result = true,
            });
        }