public JsonPatchDocument <ApiCallTypeServerRequestModel> CreatePatch(ApiCallTypeServerRequestModel model) { var patch = new JsonPatchDocument <ApiCallTypeServerRequestModel>(); patch.Replace(x => x.Name, model.Name); return(patch); }
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"); }
public virtual ApiCallTypeServerResponseModel MapServerRequestToResponse( int id, ApiCallTypeServerRequestModel request) { var response = new ApiCallTypeServerResponseModel(); response.SetProperties(id, request.Name); return(response); }
public virtual CallType MapModelToEntity( int id, ApiCallTypeServerRequestModel model ) { CallType item = new CallType(); item.SetProperties( id, model.Name); return(item); }
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); }
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)); } }