public virtual async Task <TDto> CopyAsync(TId id)
        {
            var copiedEntity = await _service.CopyAsync(id);

            await _repository.SaveChangesAsync();

            return(_mapper.Map <TDto>(copiedEntity));
        }
예제 #2
0
        public virtual async Task <ActionResult <T2> > Copy(T1 id)
        {
            try
            {
                var createdEntity = await _service.CopyAsync(id);

                return(CreatedAtAction(nameof(GetById), new { id = createdEntity.Id }, createdEntity));
            }
            catch (EntityNotFoundException)
            {
                return(NotFound());
            }
        }
        /// <summary>
        /// Creates the asynchronous.
        /// </summary>
        /// <param name="entity">The entity.</param>
        /// <returns></returns>
        public virtual async Task <T2> CopyAsync(T1 id)
        {
            var createdEntity = await _service.CopyAsync(id);

            var historicalEvent = new HistoricalEvent
            {
                Action    = HistoricalActions.Create.ToString(),
                Changeset = new HistoricalChangeset()
                {
                    ObjectDelta = new T2().DetailedCompare(createdEntity)
                },
                EntityId   = createdEntity.Id.ToString(),
                EntityName = createdEntity.GetType().FullName
            };

            await _repository.CreateAsync <Guid, HistoricalEvent>(historicalEvent);

            await _repository.SaveChangesAsync();

            return(createdEntity);
        }
예제 #4
0
 public virtual async Task <T> CopyAsync(Guid id) => await _service.CopyAsync(id);
예제 #5
0
 public async Task <T2> CopyAsync(T1 id) => await _service.CopyAsync(id);