Esempio n. 1
0
        public JsonPatchDocument <ApiCallTypeServerRequestModel> CreatePatch(ApiCallTypeServerRequestModel model)
        {
            var patch = new JsonPatchDocument <ApiCallTypeServerRequestModel>();

            patch.Replace(x => x.Name, model.Name);
            return(patch);
        }
Esempio n. 2
0
        public virtual ApiCallTypeServerRequestModel MapServerResponseToRequest(
            ApiCallTypeServerResponseModel response)
        {
            var request = new ApiCallTypeServerRequestModel();

            request.SetProperties(
                response.Name);
            return(request);
        }
        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");
        }
Esempio n. 4
0
        public virtual ApiCallTypeServerResponseModel MapServerRequestToResponse(
            int id,
            ApiCallTypeServerRequestModel request)
        {
            var response = new ApiCallTypeServerResponseModel();

            response.SetProperties(id,
                                   request.Name);
            return(response);
        }
Esempio n. 5
0
        public virtual CallType MapModelToEntity(
            int id,
            ApiCallTypeServerRequestModel model
            )
        {
            CallType item = new CallType();

            item.SetProperties(
                id,
                model.Name);
            return(item);
        }
Esempio n. 6
0
        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);
        }
Esempio n. 7
0
        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));
            }
        }