public virtual async Task <ActionResponse> Delete(
            int id)
        {
            ActionResponse response = ValidationResponseFactory <object> .ActionResponse(await this.TransactionModelValidator.ValidateDeleteAsync(id));

            if (response.Success)
            {
                await this.TransactionRepository.Delete(id);

                await this.mediator.Publish(new TransactionDeletedNotification(id));
            }

            return(response);
        }
        public virtual async Task <CreateResponse <ApiTransactionServerResponseModel> > Create(
            ApiTransactionServerRequestModel model)
        {
            CreateResponse <ApiTransactionServerResponseModel> response = ValidationResponseFactory <ApiTransactionServerResponseModel> .CreateResponse(await this.TransactionModelValidator.ValidateCreateAsync(model));

            if (response.Success)
            {
                Transaction record = this.DalTransactionMapper.MapModelToEntity(default(int), model);
                record = await this.TransactionRepository.Create(record);

                response.SetRecord(this.DalTransactionMapper.MapEntityToModel(record));
                await this.mediator.Publish(new TransactionCreatedNotification(response.Record));
            }

            return(response);
        }
        public virtual async Task <UpdateResponse <ApiTransactionServerResponseModel> > Update(
            int id,
            ApiTransactionServerRequestModel model)
        {
            var validationResult = await this.TransactionModelValidator.ValidateUpdateAsync(id, model);

            if (validationResult.IsValid)
            {
                Transaction record = this.DalTransactionMapper.MapModelToEntity(id, model);
                await this.TransactionRepository.Update(record);

                record = await this.TransactionRepository.Get(id);

                ApiTransactionServerResponseModel apiModel = this.DalTransactionMapper.MapEntityToModel(record);
                await this.mediator.Publish(new TransactionUpdatedNotification(apiModel));

                return(ValidationResponseFactory <ApiTransactionServerResponseModel> .UpdateResponse(apiModel));
            }
            else
            {
                return(ValidationResponseFactory <ApiTransactionServerResponseModel> .UpdateResponse(validationResult));
            }
        }