public virtual ApiTransactionStatusServerRequestModel MapServerResponseToRequest(
            ApiTransactionStatusServerResponseModel response)
        {
            var request = new ApiTransactionStatusServerRequestModel();

            request.SetProperties(
                response.Name);
            return(request);
        }
        public void MapModelToEntity()
        {
            var mapper = new DALTransactionStatusMapper();
            ApiTransactionStatusServerRequestModel model = new ApiTransactionStatusServerRequestModel();

            model.SetProperties("A");
            TransactionStatus response = mapper.MapModelToEntity(1, model);

            response.Name.Should().Be("A");
        }
        public virtual ApiTransactionStatusServerResponseModel MapServerRequestToResponse(
            int id,
            ApiTransactionStatusServerRequestModel request)
        {
            var response = new ApiTransactionStatusServerResponseModel();

            response.SetProperties(id,
                                   request.Name);
            return(response);
        }
示例#4
0
        public virtual TransactionStatus MapModelToEntity(
            int id,
            ApiTransactionStatusServerRequestModel model
            )
        {
            TransactionStatus item = new TransactionStatus();

            item.SetProperties(
                id,
                model.Name);
            return(item);
        }
        public virtual async Task <CreateResponse <ApiTransactionStatusServerResponseModel> > Create(
            ApiTransactionStatusServerRequestModel model)
        {
            CreateResponse <ApiTransactionStatusServerResponseModel> response = ValidationResponseFactory <ApiTransactionStatusServerResponseModel> .CreateResponse(await this.TransactionStatusModelValidator.ValidateCreateAsync(model));

            if (response.Success)
            {
                TransactionStatus record = this.DalTransactionStatusMapper.MapModelToEntity(default(int), model);
                record = await this.TransactionStatusRepository.Create(record);

                response.SetRecord(this.DalTransactionStatusMapper.MapEntityToModel(record));
                await this.mediator.Publish(new TransactionStatusCreatedNotification(response.Record));
            }

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

            if (validationResult.IsValid)
            {
                TransactionStatus record = this.DalTransactionStatusMapper.MapModelToEntity(id, model);
                await this.TransactionStatusRepository.Update(record);

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

                ApiTransactionStatusServerResponseModel apiModel = this.DalTransactionStatusMapper.MapEntityToModel(record);
                await this.mediator.Publish(new TransactionStatusUpdatedNotification(apiModel));

                return(ValidationResponseFactory <ApiTransactionStatusServerResponseModel> .UpdateResponse(apiModel));
            }
            else
            {
                return(ValidationResponseFactory <ApiTransactionStatusServerResponseModel> .UpdateResponse(validationResult));
            }
        }
        public JsonPatchDocument <ApiTransactionStatusServerRequestModel> CreatePatch(ApiTransactionStatusServerRequestModel model)
        {
            var patch = new JsonPatchDocument <ApiTransactionStatusServerRequestModel>();

            patch.Replace(x => x.Name, model.Name);
            return(patch);
        }