/// <summary>
 /// Determines whether the specified macros are valid.
 /// </summary>
 /// <param name="macros">The macros.</param>
 /// <returns>
 ///   <c>true</c> if the specified macros are valid; otherwise, <c>false</c>.
 /// </returns>
 public bool IsValid(IEnumerable <MacroDto> macros)
 {
     foreach (var macro in macros)
     {
         if (!MacroBuilder.IsValidExpression(macro.Expression))
         {
             return(false);
         }
     }
     return(true);
 }
Esempio n. 2
0
 /// <summary>
 /// Updates the specified item.
 /// </summary>
 /// <param name="item">The item.</param>
 public void Update(MacroDto item)
 {
     if (item == null)
     {
         return;
     }
     else if (!MacroBuilder.IsValidExpression(item.Expression))
     {
         throw new InvalidMacroException();
     }
     else
     {
         var entity = this.Session.Get <Macro>(item.Id);
         Mapper.Map <MacroDto, Macro>(item, entity);
         if (entity != null)
         {
             this.Session.Update(entity);
         }
     }
 }
Esempio n. 3
0
        public long Create(MacroDto item)
        {
            Assert.IsNotNull(item, "item");

            if (!MacroBuilder.IsValidExpression(item.Expression))
            {
                throw new InvalidMacroException();
            }

            var exist = (from i in this.Session.Query <MacroDto>()
                         where i.Id == item.Id
                         select i).ToList().Count() > 0;

            if (exist)
            {
                throw new ExistingItemException();
            }

            var entity = Mapper.Map <MacroDto, Macro>(item);

            item.Id = (long)this.Session.Save(entity);
            return(item.Id);
        }
 /// <summary>
 /// Determines whether the specified macro is valid.
 /// </summary>
 /// <param name="macro"></param>
 /// <returns>
 ///   <c>true</c> if macro is valid; otherwise, <c>false</c>.
 /// </returns>
 public bool IsValid(MacroDto macro)
 {
     return((macro != null)
         ? MacroBuilder.IsValidExpression(macro.Expression)
         : false);
 }