/// <summary>
 /// Create new <see cref="Data.Models.Accountant"/> based on <see cref="DeleteAccountantCommand"/>
 /// </summary>
 /// <param name="command">Accountant details</param>
 /// <returns>Data model</returns>
 internal Data.Models.Accountant Create(DeleteAccountantCommand command)
 {
     return(new Data.Models.Accountant
     {
         Id = command.Id,
         IsRemoved = true,
         LastModificationDate = DateTime.UtcNow
     });
 }
        /// <summary>
        /// Handle <see cref="DeleteAccountantCommand"/>
        /// </summary>
        /// <param name="command">Command object</param>
        public async Task HandleImmediateAsync(DeleteAccountantCommand command)
        {
            Data.Models.Accountant model = accountantFactory.Create(command);
            DataContext.Accountants.Attach(model);

            DataContext.SetPropertyModified(model, nameof(model.IsRemoved));
            DataContext.SetPropertyModified(model, nameof(model.LastModificationDate));

            await this.Finalize();
        }
Пример #3
0
        public async Task <IActionResult> Delete(Guid id)
        {
            DeleteAccountantCommand command = new DeleteAccountantCommand(id);

            try
            {
                await this.commandBus.SendAsync(command);
            }
            catch
            {
                return(BadRequest("Failed to delete accountant."));
            }

            return(Ok());
        }