public JsonPatchDocument <ApiLinkTypeServerRequestModel> CreatePatch(ApiLinkTypeServerRequestModel model)
        {
            var patch = new JsonPatchDocument <ApiLinkTypeServerRequestModel>();

            patch.Replace(x => x.RwType, model.RwType);
            return(patch);
        }
        public virtual ApiLinkTypeServerRequestModel MapServerResponseToRequest(
            ApiLinkTypeServerResponseModel response)
        {
            var request = new ApiLinkTypeServerRequestModel();

            request.SetProperties(
                response.RwType);
            return(request);
        }
        public virtual ApiLinkTypeServerResponseModel MapServerRequestToResponse(
            int id,
            ApiLinkTypeServerRequestModel request)
        {
            var response = new ApiLinkTypeServerResponseModel();

            response.SetProperties(id,
                                   request.RwType);
            return(response);
        }
Пример #4
0
        public void MapModelToEntity()
        {
            var mapper = new DALLinkTypeMapper();
            ApiLinkTypeServerRequestModel model = new ApiLinkTypeServerRequestModel();

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

            response.RwType.Should().Be("A");
        }
Пример #5
0
        public virtual LinkType MapModelToEntity(
            int id,
            ApiLinkTypeServerRequestModel model
            )
        {
            LinkType item = new LinkType();

            item.SetProperties(
                id,
                model.RwType);
            return(item);
        }
Пример #6
0
        public virtual async Task <CreateResponse <ApiLinkTypeServerResponseModel> > Create(
            ApiLinkTypeServerRequestModel model)
        {
            CreateResponse <ApiLinkTypeServerResponseModel> response = ValidationResponseFactory <ApiLinkTypeServerResponseModel> .CreateResponse(await this.LinkTypeModelValidator.ValidateCreateAsync(model));

            if (response.Success)
            {
                LinkType record = this.DalLinkTypeMapper.MapModelToEntity(default(int), model);
                record = await this.LinkTypeRepository.Create(record);

                response.SetRecord(this.DalLinkTypeMapper.MapEntityToModel(record));
                await this.mediator.Publish(new LinkTypeCreatedNotification(response.Record));
            }

            return(response);
        }
Пример #7
0
        public virtual async Task <UpdateResponse <ApiLinkTypeServerResponseModel> > Update(
            int id,
            ApiLinkTypeServerRequestModel model)
        {
            var validationResult = await this.LinkTypeModelValidator.ValidateUpdateAsync(id, model);

            if (validationResult.IsValid)
            {
                LinkType record = this.DalLinkTypeMapper.MapModelToEntity(id, model);
                await this.LinkTypeRepository.Update(record);

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

                ApiLinkTypeServerResponseModel apiModel = this.DalLinkTypeMapper.MapEntityToModel(record);
                await this.mediator.Publish(new LinkTypeUpdatedNotification(apiModel));

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