コード例 #1
0
        public JsonPatchDocument <ApiCallTypeServerRequestModel> CreatePatch(ApiCallTypeServerRequestModel model)
        {
            var patch = new JsonPatchDocument <ApiCallTypeServerRequestModel>();

            patch.Replace(x => x.Name, model.Name);
            return(patch);
        }
コード例 #2
0
        public virtual ApiCallTypeServerRequestModel MapServerResponseToRequest(
            ApiCallTypeServerResponseModel response)
        {
            var request = new ApiCallTypeServerRequestModel();

            request.SetProperties(
                response.Name);
            return(request);
        }
コード例 #3
0
        public void MapModelToEntity()
        {
            var mapper = new DALCallTypeMapper();
            ApiCallTypeServerRequestModel model = new ApiCallTypeServerRequestModel();

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

            response.Name.Should().Be("A");
        }
コード例 #4
0
        public virtual ApiCallTypeServerResponseModel MapServerRequestToResponse(
            int id,
            ApiCallTypeServerRequestModel request)
        {
            var response = new ApiCallTypeServerResponseModel();

            response.SetProperties(id,
                                   request.Name);
            return(response);
        }
コード例 #5
0
        public virtual CallType MapModelToEntity(
            int id,
            ApiCallTypeServerRequestModel model
            )
        {
            CallType item = new CallType();

            item.SetProperties(
                id,
                model.Name);
            return(item);
        }
コード例 #6
0
ファイル: CallTypeService.cs プロジェクト: codenesium/samples
        public virtual async Task <CreateResponse <ApiCallTypeServerResponseModel> > Create(
            ApiCallTypeServerRequestModel model)
        {
            CreateResponse <ApiCallTypeServerResponseModel> response = ValidationResponseFactory <ApiCallTypeServerResponseModel> .CreateResponse(await this.CallTypeModelValidator.ValidateCreateAsync(model));

            if (response.Success)
            {
                CallType record = this.DalCallTypeMapper.MapModelToEntity(default(int), model);
                record = await this.CallTypeRepository.Create(record);

                response.SetRecord(this.DalCallTypeMapper.MapEntityToModel(record));
                await this.mediator.Publish(new CallTypeCreatedNotification(response.Record));
            }

            return(response);
        }
コード例 #7
0
ファイル: CallTypeService.cs プロジェクト: codenesium/samples
        public virtual async Task <UpdateResponse <ApiCallTypeServerResponseModel> > Update(
            int id,
            ApiCallTypeServerRequestModel model)
        {
            var validationResult = await this.CallTypeModelValidator.ValidateUpdateAsync(id, model);

            if (validationResult.IsValid)
            {
                CallType record = this.DalCallTypeMapper.MapModelToEntity(id, model);
                await this.CallTypeRepository.Update(record);

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

                ApiCallTypeServerResponseModel apiModel = this.DalCallTypeMapper.MapEntityToModel(record);
                await this.mediator.Publish(new CallTypeUpdatedNotification(apiModel));

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