Пример #1
0
        public async Task SetValueAsync(IDeferredItem <TItem> item, object deserializedValue, IDataTransaction dataTransaction)
        {
            TNav navValue = ConversionUtility.ConvertValue <TNav>(deserializedValue);

            await item.LoadAsync();

            _setter.SetNavItem(item.LoadedItem, navValue);
        }
Пример #2
0
        public async Task SetValueAsync(IDeferredItem <TItem> item, object deserializedValue, IDataTransaction dataTransaction)
        {
            await item.LoadAsync(); // TODO: and do we want to load items within the set function?

            TValue newValue = ConversionUtility.CleverConvertValue <TValue>(deserializedValue);

            _setterAction(item.LoadedItem, newValue);
        }
Пример #3
0
        public async Task SetValueAsync(IDeferredItem <TItem> item, object deserializedValue, IDataTransaction dataTransaction)
        {
            await item.LoadAsync();

            if (item.LoadedItem == null)
            {
                throw new ArgumentNullException(nameof(item.LoadedItem), "Cannot set field value for this item because the item is null.");
            }

            object convertedValue = ConversionUtility.ConvertValue(deserializedValue, _propertyInfo.PropertyType);

            _propertyInfo.SetValue(item.LoadedItem, convertedValue);
        }
Пример #4
0
        public async Task <Acknowledgment> EditAsync(RestItemData itemData)
        {
            if (!_context.AuthorizationChecker.CanEditItem(_item))
            {
                throw new NotAuthorizedForItemException(AuthorizableVerb.Edit);
            }

            var setter = new QueryableFieldSetter <TItem>(_context);
            await setter.SetMappedValuesAsync(_item, itemData);

            await _item.LoadAsync();

            _context.Repository.MarkUpdated(_item.LoadedItem);

            await _context.Transaction.SaveChangesAsync();

            if (_item.WasCreated)
            {
                return(new CreatedItemAcknowledgment(_item.Identifier));
            }

            return(new Acknowledgment());
        }
Пример #5
0
        public async Task <Acknowledgment> EditAsync(object value)
        {
            if (!_context.AuthorizationChecker.CanEditField(_item, _field))
            {
                throw new NotAuthorizedForFieldException(AuthorizableVerb.Edit, _field.Name);
            }

            await _item.LoadAsync(); // TODO: is this necessary?

            await _field.Writer.SetValueAsync(_item, value, _context.Transaction);

            _context.Repository.MarkUpdated(_item.LoadedItem);

            await _context.Transaction.SaveChangesAsync();

            return(new Acknowledgment());
        }
 public async Task InitializeAsync()
 {
     // currently this is the only time this method is used.. perhaps this can be combined with CreateAndAttachItem ?
     await _parentItem.LoadAsync();
 }