Ejemplo n.º 1
0
        public JsonPatchDocument <ApiChainStatusServerRequestModel> CreatePatch(ApiChainStatusServerRequestModel model)
        {
            var patch = new JsonPatchDocument <ApiChainStatusServerRequestModel>();

            patch.Replace(x => x.Name, model.Name);
            return(patch);
        }
Ejemplo n.º 2
0
        public virtual ApiChainStatusServerRequestModel MapServerResponseToRequest(
            ApiChainStatusServerResponseModel response)
        {
            var request = new ApiChainStatusServerRequestModel();

            request.SetProperties(
                response.Name);
            return(request);
        }
Ejemplo n.º 3
0
        public void MapModelToEntity()
        {
            var mapper = new DALChainStatusMapper();
            ApiChainStatusServerRequestModel model = new ApiChainStatusServerRequestModel();

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

            response.Name.Should().Be("A");
        }
Ejemplo n.º 4
0
        public virtual ApiChainStatusServerResponseModel MapServerRequestToResponse(
            int id,
            ApiChainStatusServerRequestModel request)
        {
            var response = new ApiChainStatusServerResponseModel();

            response.SetProperties(id,
                                   request.Name);
            return(response);
        }
Ejemplo n.º 5
0
        public virtual ChainStatus MapModelToEntity(
            int id,
            ApiChainStatusServerRequestModel model
            )
        {
            ChainStatus item = new ChainStatus();

            item.SetProperties(
                id,
                model.Name);
            return(item);
        }
Ejemplo n.º 6
0
        public virtual async Task <CreateResponse <ApiChainStatusServerResponseModel> > Create(
            ApiChainStatusServerRequestModel model)
        {
            CreateResponse <ApiChainStatusServerResponseModel> response = ValidationResponseFactory <ApiChainStatusServerResponseModel> .CreateResponse(await this.ChainStatusModelValidator.ValidateCreateAsync(model));

            if (response.Success)
            {
                ChainStatus record = this.DalChainStatusMapper.MapModelToEntity(default(int), model);
                record = await this.ChainStatusRepository.Create(record);

                response.SetRecord(this.DalChainStatusMapper.MapEntityToModel(record));
                await this.mediator.Publish(new ChainStatusCreatedNotification(response.Record));
            }

            return(response);
        }
Ejemplo n.º 7
0
        public virtual async Task <UpdateResponse <ApiChainStatusServerResponseModel> > Update(
            int id,
            ApiChainStatusServerRequestModel model)
        {
            var validationResult = await this.ChainStatusModelValidator.ValidateUpdateAsync(id, model);

            if (validationResult.IsValid)
            {
                ChainStatus record = this.DalChainStatusMapper.MapModelToEntity(id, model);
                await this.ChainStatusRepository.Update(record);

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

                ApiChainStatusServerResponseModel apiModel = this.DalChainStatusMapper.MapEntityToModel(record);
                await this.mediator.Publish(new ChainStatusUpdatedNotification(apiModel));

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