public JsonPatchDocument <ApiHandlerServerRequestModel> CreatePatch(ApiHandlerServerRequestModel model) { var patch = new JsonPatchDocument <ApiHandlerServerRequestModel>(); patch.Replace(x => x.CountryId, model.CountryId); patch.Replace(x => x.Email, model.Email); patch.Replace(x => x.FirstName, model.FirstName); patch.Replace(x => x.LastName, model.LastName); patch.Replace(x => x.Phone, model.Phone); return(patch); }
public virtual ApiHandlerServerRequestModel MapServerResponseToRequest( ApiHandlerServerResponseModel response) { var request = new ApiHandlerServerRequestModel(); request.SetProperties( response.CountryId, response.Email, response.FirstName, response.LastName, response.Phone); return(request); }
public void MapModelToEntity() { var mapper = new DALHandlerMapper(); ApiHandlerServerRequestModel model = new ApiHandlerServerRequestModel(); model.SetProperties(1, "A", "A", "A", "A"); Handler response = mapper.MapModelToEntity(1, model); response.CountryId.Should().Be(1); response.Email.Should().Be("A"); response.FirstName.Should().Be("A"); response.LastName.Should().Be("A"); response.Phone.Should().Be("A"); }
public virtual ApiHandlerServerResponseModel MapServerRequestToResponse( int id, ApiHandlerServerRequestModel request) { var response = new ApiHandlerServerResponseModel(); response.SetProperties(id, request.CountryId, request.Email, request.FirstName, request.LastName, request.Phone); return(response); }
public virtual async Task <CreateResponse <ApiHandlerServerResponseModel> > Create( ApiHandlerServerRequestModel model) { CreateResponse <ApiHandlerServerResponseModel> response = ValidationResponseFactory <ApiHandlerServerResponseModel> .CreateResponse(await this.HandlerModelValidator.ValidateCreateAsync(model)); if (response.Success) { Handler record = this.DalHandlerMapper.MapModelToEntity(default(int), model); record = await this.HandlerRepository.Create(record); response.SetRecord(this.DalHandlerMapper.MapEntityToModel(record)); await this.mediator.Publish(new HandlerCreatedNotification(response.Record)); } return(response); }
public virtual Handler MapModelToEntity( int id, ApiHandlerServerRequestModel model ) { Handler item = new Handler(); item.SetProperties( id, model.CountryId, model.Email, model.FirstName, model.LastName, model.Phone); return(item); }
public virtual async Task <UpdateResponse <ApiHandlerServerResponseModel> > Update( int id, ApiHandlerServerRequestModel model) { var validationResult = await this.HandlerModelValidator.ValidateUpdateAsync(id, model); if (validationResult.IsValid) { Handler record = this.DalHandlerMapper.MapModelToEntity(id, model); await this.HandlerRepository.Update(record); record = await this.HandlerRepository.Get(id); ApiHandlerServerResponseModel apiModel = this.DalHandlerMapper.MapEntityToModel(record); await this.mediator.Publish(new HandlerUpdatedNotification(apiModel)); return(ValidationResponseFactory <ApiHandlerServerResponseModel> .UpdateResponse(apiModel)); } else { return(ValidationResponseFactory <ApiHandlerServerResponseModel> .UpdateResponse(validationResult)); } }