public async Task <EntityVersion <WebResourceName, string> > TryUpdate(
            WebResourceName entityId,
            string entityVersion,
            vCard entityToUpdate,
            Func <vCard, vCard> entityModifier)
        {
            using (AutomaticStopwatch.StartDebug(s_logger))
            {
                vCard newVcard = new vCard();
                newVcard.UniqueId = (!string.IsNullOrEmpty(entityToUpdate.UniqueId)) ? entityToUpdate.UniqueId : Guid.NewGuid().ToString();
                newVcard          = entityModifier(newVcard);

                return(await _cardDavDataAccess.TryUpdateEntity(entityId, entityVersion, Serialize (newVcard)));
            }
        }
Example #2
0
        public async Task <EntityVersion <WebResourceName, string> > TryUpdate(
            WebResourceName entityId,
            string entityVersion,
            TEntity entityToUpdate,
            Func <TEntity, Task <TEntity> > entityModifier,
            TContext context)
        {
            using (AutomaticStopwatch.StartDebug(s_logger))
            {
                var updatedEntity = await entityModifier(entityToUpdate);

                if (string.IsNullOrEmpty(GetUid(updatedEntity)))
                {
                    SetUid(updatedEntity, Guid.NewGuid().ToString());
                }
                return(await _cardDavDataAccess.TryUpdateEntity(entityId, entityVersion, Serialize (updatedEntity)));
            }
        }