Beispiel #1
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;
        }
 private ICommand BuildMenuItemCommand(MacroDto macro)
 {
     return new RelayCommand(() =>
     {
         var text = this.Component.Resolve(macro, PluginContext.Host.SelectedPatient);
         //TextEditor.Control.CaretPosition.InsertTextInRun(text);
         TextEditor.Control.Selection.Text = text;
     });
 }
Beispiel #3
0
 public static void SetMacro(DependencyObject target, MacroDto value)
 {
     target.SetValue(ProfessionProperty, value);
 }
 /// <summary>
 /// Creates the specified macro.
 /// </summary>
 /// <param name="macro">The macro.</param>
 /// <returns>The id of the created macro</returns>
 public long Create(MacroDto macro)
 {
     return new Creator(this.Session).Create(macro);
 }
 /// <summary>
 /// Updates the specified macro.
 /// </summary>
 /// <param name="macro">The macro.</param>
 public void Update(MacroDto macro)
 {
     new Updator(this.Session).Update(macro);
 }
        /// <summary>
        /// Resolves the specified macro with the data of the specified patient.
        /// </summary>
        /// <param name="macro">The macro.</param>
        /// <param name="patient">The patient.</param>
        /// <returns></returns>
        public string Resolve(MacroDto macro, LightPatientDto patient)
        {
            if (macro == null || patient == null) return string.Empty;

            var p = this.Session.Get<Patient>(patient.Id);
            if (p == null) throw new EntityNotFoundException(typeof(Patient));

            var builder = new MacroBuilder(p);
            return builder.Resolve(macro.Expression);
        }
 /// <summary>
 /// Removes the specified item.
 /// </summary>
 /// <param name="item">The item.</param>
 public void Remove(MacroDto item)
 {
     new Remover(this.Session).Remove(item);
 }
 /// <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;
 }
 private void Create()
 {
     try
     {
         var macro = new MacroDto() { Title = Messages.Macro_New };
         this.Component.Create(macro);
         this.Macros.Add(macro);
     }
     catch (Exception ex) { this.Handle.Error(ex); }
 }