public JsonPatchDocument <ApiReplyServerRequestModel> CreatePatch(ApiReplyServerRequestModel model) { var patch = new JsonPatchDocument <ApiReplyServerRequestModel>(); patch.Replace(x => x.Content, model.Content); patch.Replace(x => x.Date, model.Date); patch.Replace(x => x.ReplierUserId, model.ReplierUserId); patch.Replace(x => x.Time, model.Time); return(patch); }
public virtual ApiReplyServerRequestModel MapServerResponseToRequest( ApiReplyServerResponseModel response) { var request = new ApiReplyServerRequestModel(); request.SetProperties( response.Content, response.Date, response.ReplierUserId, response.Time); return(request); }
public void MapModelToEntity() { var mapper = new DALReplyMapper(); ApiReplyServerRequestModel model = new ApiReplyServerRequestModel(); model.SetProperties("A", DateTime.Parse("1/1/1987 12:00:00 AM"), 1, TimeSpan.Parse("01:00:00")); Reply response = mapper.MapModelToEntity(1, model); response.Content.Should().Be("A"); response.Date.Should().Be(DateTime.Parse("1/1/1987 12:00:00 AM")); response.ReplierUserId.Should().Be(1); response.Time.Should().Be(TimeSpan.Parse("01:00:00")); }
public virtual ApiReplyServerResponseModel MapServerRequestToResponse( int replyId, ApiReplyServerRequestModel request) { var response = new ApiReplyServerResponseModel(); response.SetProperties(replyId, request.Content, request.Date, request.ReplierUserId, request.Time); return(response); }
public virtual Reply MapModelToEntity( int replyId, ApiReplyServerRequestModel model ) { Reply item = new Reply(); item.SetProperties( replyId, model.Content, model.Date, model.ReplierUserId, model.Time); return(item); }
public virtual async Task <CreateResponse <ApiReplyServerResponseModel> > Create( ApiReplyServerRequestModel model) { CreateResponse <ApiReplyServerResponseModel> response = ValidationResponseFactory <ApiReplyServerResponseModel> .CreateResponse(await this.ReplyModelValidator.ValidateCreateAsync(model)); if (response.Success) { Reply record = this.DalReplyMapper.MapModelToEntity(default(int), model); record = await this.ReplyRepository.Create(record); response.SetRecord(this.DalReplyMapper.MapEntityToModel(record)); await this.mediator.Publish(new ReplyCreatedNotification(response.Record)); } return(response); }
public virtual async Task <UpdateResponse <ApiReplyServerResponseModel> > Update( int replyId, ApiReplyServerRequestModel model) { var validationResult = await this.ReplyModelValidator.ValidateUpdateAsync(replyId, model); if (validationResult.IsValid) { Reply record = this.DalReplyMapper.MapModelToEntity(replyId, model); await this.ReplyRepository.Update(record); record = await this.ReplyRepository.Get(replyId); ApiReplyServerResponseModel apiModel = this.DalReplyMapper.MapEntityToModel(record); await this.mediator.Publish(new ReplyUpdatedNotification(apiModel)); return(ValidationResponseFactory <ApiReplyServerResponseModel> .UpdateResponse(apiModel)); } else { return(ValidationResponseFactory <ApiReplyServerResponseModel> .UpdateResponse(validationResult)); } }