Exemplo n.º 1
0
        public void Delete(string uri, Guid userID, string email, int tenantId = 0)
        {
            var authorization = GetSystemAuthorization();
            var deleteUrlBook = GetRadicaleUrl(uri, email.ToLower(), true, true);
            var davRequest    = new DavRequest()
            {
                Url           = deleteUrlBook,
                Authorization = authorization
            };

            try
            {
                RadicaleClient.RemoveAsync(davRequest).ConfigureAwait(false);
                var dbConn = new DbRadicale();
                dbConn.RemoveCardDavUser(tenantId, userID.ToString());
            }
            catch (Exception ex)
            {
                Logger.Error("ERROR: " + ex.Message);
            }
        }
Exemplo n.º 2
0
        public void UpdateItemForAllAddBooks(List <string> emailList, string uri, CardDavItem user, int tenantId = 0, string changedEmail = null)
        {
            var authorization = GetSystemAuthorization();

            if (changedEmail != null)
            {
                var deleteUrlBook = GetRadicaleUrl(uri, changedEmail.ToLower(), true, true);
                var davRequest    = new DavRequest()
                {
                    Url           = deleteUrlBook,
                    Authorization = authorization
                };
                RadicaleClient.RemoveAsync(davRequest).ConfigureAwait(false);

                try
                {
                    var dbConn = new DbRadicale();
                    dbConn.RemoveCardDavUser(tenantId, user.ID.ToString());
                }
                catch (Exception ex)
                {
                    Logger.Error("ERROR: " + ex.Message);
                }
            }

            foreach (string email in emailList)
            {
                try
                {
                    var currentEmail = email.ToLower();
                    var userData     = GetUserSerialization(user);
                    var requestUrl   = GetRadicaleUrl(uri, currentEmail, true, true, itemID: user.ID.ToString());
                    UpdateItem(requestUrl, authorization, userData, uri).ConfigureAwait(false);
                }
                catch (Exception ex)
                {
                    Logger.Error("ERROR: " + ex.Message);
                }
            }
        }