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)); }
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)); }
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; }
/// <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); } }
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());
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);
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);
public static bool Equal <T, TV>(this IEntityGetter <T> accessor, string attribute, TV comparisonValue) where T : Entity => Equal(accessor.Get <TV>(attribute), comparisonValue);
public static string GetFormattedValue <T>(this IEntityGetter <T> accessor, Expression <Func <T, object> > attribute) where T : Entity => accessor.GetFormattedValue(Name(attribute));
public static TV GetAliasedValue <TV>(this IEntityGetter <Entity> accessor, string attributeName) => (TV)accessor.Get <AliasedValue>(attributeName)?.Value;
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);
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;
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);