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

            patch.Replace(x => x.Name, model.Name);
            return(patch);
        }
        public virtual ApiCallDispositionServerRequestModel MapServerResponseToRequest(
            ApiCallDispositionServerResponseModel response)
        {
            var request = new ApiCallDispositionServerRequestModel();

            request.SetProperties(
                response.Name);
            return(request);
        }
        public virtual ApiCallDispositionServerResponseModel MapServerRequestToResponse(
            int id,
            ApiCallDispositionServerRequestModel request)
        {
            var response = new ApiCallDispositionServerResponseModel();

            response.SetProperties(id,
                                   request.Name);
            return(response);
        }
        public void MapModelToEntity()
        {
            var mapper = new DALCallDispositionMapper();
            ApiCallDispositionServerRequestModel model = new ApiCallDispositionServerRequestModel();

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

            response.Name.Should().Be("A");
        }
Example #5
0
        public virtual CallDisposition MapModelToEntity(
            int id,
            ApiCallDispositionServerRequestModel model
            )
        {
            CallDisposition item = new CallDisposition();

            item.SetProperties(
                id,
                model.Name);
            return(item);
        }
Example #6
0
        public virtual async Task <CreateResponse <ApiCallDispositionServerResponseModel> > Create(
            ApiCallDispositionServerRequestModel model)
        {
            CreateResponse <ApiCallDispositionServerResponseModel> response = ValidationResponseFactory <ApiCallDispositionServerResponseModel> .CreateResponse(await this.CallDispositionModelValidator.ValidateCreateAsync(model));

            if (response.Success)
            {
                CallDisposition record = this.DalCallDispositionMapper.MapModelToEntity(default(int), model);
                record = await this.CallDispositionRepository.Create(record);

                response.SetRecord(this.DalCallDispositionMapper.MapEntityToModel(record));
                await this.mediator.Publish(new CallDispositionCreatedNotification(response.Record));
            }

            return(response);
        }
Example #7
0
        public virtual async Task <UpdateResponse <ApiCallDispositionServerResponseModel> > Update(
            int id,
            ApiCallDispositionServerRequestModel model)
        {
            var validationResult = await this.CallDispositionModelValidator.ValidateUpdateAsync(id, model);

            if (validationResult.IsValid)
            {
                CallDisposition record = this.DalCallDispositionMapper.MapModelToEntity(id, model);
                await this.CallDispositionRepository.Update(record);

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

                ApiCallDispositionServerResponseModel apiModel = this.DalCallDispositionMapper.MapEntityToModel(record);
                await this.mediator.Publish(new CallDispositionUpdatedNotification(apiModel));

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