Exemplo n.º 1
0
        private void Execute(Guid guid, Action <Kada> callback, int counter = 0)
        {
            try
            {
                var kada = Kade.Find(guid.ToString());
                if (kada == null)
                {
                    throw new ArgumentException("Kada sa GUID-om '" + guid.ToString() + "' ne postoji!");
                }

                callback(kada);
                Kade.Update(kada);
            }
            catch
            {
                if (counter < 5)
                {
                    Thread.Sleep(25);
                    Execute(guid, callback, counter + 1);
                }
                else
                {
                    throw;
                }
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Update changed aggregate root.
        /// Aggregate is modified in place.
        /// </summary>
        /// <typeparam name="TRoot">aggregate type</typeparam>
        /// <param name="repository">persistable repository</param>
        /// <param name="data">changed aggregate</param>
        public static void Update <TRoot>(this IPersistableRepository <TRoot> repository, TRoot data)
            where TRoot : IAggregateRoot
        {
            Contract.Requires(repository != null);

            repository.Update(new[] { data });
        }
Exemplo n.º 3
0
 public static Task Update <T>(this IPersistableRepository <T> repository, T data)
     where T : class, IAggregateRoot
 {
     if (repository == null)
     {
         throw new ArgumentNullException("repository can't be null");
     }
     return(repository.Update(new[] { data }));
 }
Exemplo n.º 4
0
        public void Handle(MarkDone domainEvent)
        {
            var task = Repository.Find(domainEvent.taskURI);

            if (task == null)
            {
                throw new ArgumentException("Cant find task with uri: " + domainEvent.taskURI);
            }
            if (task.isDone)
            {
                throw new ArgumentException("Task " + task.name + " is already marked as done!");
            }
            task.isDone = true;
            Repository.Update(task);
        }
Exemplo n.º 5
0
 private void EditCurrent(object sender, ExecutedRoutedEventArgs ea)
 {
     StateChanged(InEdit = true);
     SaveAction          = () => Repository.Update(GetCurrent());
 }