Example #1
0
        public void Can_get_money_value_from_null_accessor()
        {
            IEntityGetter <xts_entity> accessor = null;

            Assert.Equal(0m, accessor.GetValue(e => e.xts_money));
            Assert.Equal(10m, accessor.GetValue(e => e.xts_money, 10m));
        }
Example #2
0
        public void Can_get_attribute_empty_value_from_null_accessor()
        {
            IEntityGetter <xts_entity> accessor = null;

            Assert.Null(accessor.Get(e => e.xts_attribute));
            Assert.Null(accessor.Get(e => e.xts_withcolumnattribute));
            Assert.Null(accessor.Get(e => e.xts_money));
            Assert.Null(accessor.Get(e => e.xts_optionsetvalue));
        }
Example #3
0
 public OrdersController(IEntityGetter <Order, OrderItemViewModel> getter,
                         IEntityCollectionGetter <Order, OrderItemViewModel> collectionGetter,
                         IEntityCreator <OrderBindingModel, Order> creator,
                         IEntityUpdater <OrderQuantityBindingModel, Order> updater,
                         IEntityDeleter <Order> deleter)
 {
     _getter           = getter;
     _collectionGetter = collectionGetter;
     _creator          = creator;
     _deleter          = deleter;
     _updater          = updater;
 }
 public TokenController(
     LyciumNotifier notifier,
     IHostService host,
     ITokenService token,
     IContextInfoService info,
     IEntitySetter <LyciumToken> setter,
     IEntityGetter <LyciumToken> getter
     ) : base(setter, getter)
 {
     _info     = info;
     _host     = host;
     _notifier = notifier;
     _token    = token;
 }
Example #5
0
        /// <summary>
        /// Удаляет сущность из БД и возвращает истину в случает успешного выполнения операции.
        /// </summary>
        /// <param name="entity">Объект сущности</param>
        /// <param name="getter">Экземпляр класса, реализующего интерфейс <c>IEntityGetter</c></param>
        /// <returns>Результат выполнения операции</returns>
        public static bool RemoveEntity <T>(this T entity, IEntityGetter getter) where T : class, IIdentifiable
        {
            if (entity.GetDialogResultByEntityType() != DialogResult.OK)
            {
                return(false);
            }

            try
            {
                getter.RemoveEntity(entity);
                return(true);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Запись не удалена", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return(false);
            }
        }
Example #6
0
 public static bool Equal <T>(this IEntityGetter <T> accessor, Expression <Func <T, OptionSetValue> > attribute, Enum option)
     where T : Entity => Equal(Get(accessor, attribute), option.ToOptionSetValue());
Example #7
0
 public static bool EqualsAny <T>(this IEntityGetter <T> accessor, Expression <Func <T, OptionSetValue> > attribute, Enum firstOption, params Enum[] otherOptions)
     where T : Entity => EqualsAny(Get(accessor, attribute), firstOption, otherOptions);
Example #8
0
 public static bool Equal <T, TV>(this IEntityGetter <T> accessor, Expression <Func <T, TV> > attribute, TV comparisonValue)
     where T : Entity => Equal(Get(accessor, attribute), comparisonValue);
Example #9
0
 public static bool Equal <T, TV>(this IEntityGetter <T> accessor, string attribute, TV comparisonValue)
     where T : Entity => Equal(accessor.Get <TV>(attribute), comparisonValue);
Example #10
0
 public static string GetFormattedValue <T>(this IEntityGetter <T> accessor, Expression <Func <T, object> > attribute)
     where T : Entity
 => accessor.GetFormattedValue(Name(attribute));
Example #11
0
 public static TV GetAliasedValue <TV>(this IEntityGetter <Entity> accessor, string attributeName)
 => (TV)accessor.Get <AliasedValue>(attributeName)?.Value;
Example #12
0
 public static TV GetValue <T, TV>(this IEntityGetter <T> accessor, Expression <Func <T, TV?> > attribute, TV defaultValue = default(TV))
     where T : Entity
     where TV : struct
 => Get(accessor, attribute).GetValueOrDefault(defaultValue);
Example #13
0
 public static decimal GetValue <T>(this IEntityGetter <T> accessor, Expression <Func <T, Money> > moneyAttribute, decimal defaultValue = 0m)
     where T : Entity => Get(accessor, moneyAttribute)?.GetValueOrDefault(defaultValue) ?? defaultValue;
Example #14
0
 public static TV Get <T, TV>(this IEntityGetter <T> accessor, Expression <Func <T, TV> > attribute)
     where T : Entity => accessor != null?accessor.Get <TV>(Name(attribute)) : default(TV);