Beispiel #1
0
        /// <summary>
        /// Creates the specified entity.
        /// </summary>
        /// <param name="entity">The entity.</param>
        /// <returns>T.</returns>
        protected T Create(T entity)
        {
            if (entity == null)
            {
                CreateErrors.NotValid("", nameof(entity));
            }

            if (string.IsNullOrEmpty(entity?.Id.ToString()) || entity.Id.ToString() == Guid.Empty.ToString() || entity.Id.ToString() == "0")
            {
                CreateErrors.NotValid("", nameof(entity.Id));
            }

            if (Repository.Get(entity.Id) != null)
            {
                CreateErrors.ItemAlreadyExists(entity.Id);
            }

            entity.ModifiedBy(ServiceBase.GetUserName());
            entity.Validate();
            entity.Activate();
            T newEntity = Repository.Create(entity);

            _queueRepository.AddToQueue(newEntity.AddEntryToQueue <T, TId>("Create"));
            return(newEntity);
        }
 public void AddOperationToQueue(Operation operation)
 {
     activityLogger.Info("Add operation to Queue");
     repository.AddToQueue(operation);
     queueWatcher.AddWatcherUser(this);
 }