public JsonPatchDocument <ApiDirectTweetServerRequestModel> CreatePatch(ApiDirectTweetServerRequestModel model) { var patch = new JsonPatchDocument <ApiDirectTweetServerRequestModel>(); patch.Replace(x => x.Content, model.Content); patch.Replace(x => x.Date, model.Date); patch.Replace(x => x.TaggedUserId, model.TaggedUserId); patch.Replace(x => x.Time, model.Time); return(patch); }
public virtual ApiDirectTweetServerRequestModel MapServerResponseToRequest( ApiDirectTweetServerResponseModel response) { var request = new ApiDirectTweetServerRequestModel(); request.SetProperties( response.Content, response.Date, response.TaggedUserId, response.Time); return(request); }
public void MapModelToEntity() { var mapper = new DALDirectTweetMapper(); ApiDirectTweetServerRequestModel model = new ApiDirectTweetServerRequestModel(); model.SetProperties("A", DateTime.Parse("1/1/1987 12:00:00 AM"), 1, TimeSpan.Parse("01:00:00")); DirectTweet response = mapper.MapModelToEntity(1, model); response.Content.Should().Be("A"); response.Date.Should().Be(DateTime.Parse("1/1/1987 12:00:00 AM")); response.TaggedUserId.Should().Be(1); response.Time.Should().Be(TimeSpan.Parse("01:00:00")); }
public virtual ApiDirectTweetServerResponseModel MapServerRequestToResponse( int tweetId, ApiDirectTweetServerRequestModel request) { var response = new ApiDirectTweetServerResponseModel(); response.SetProperties(tweetId, request.Content, request.Date, request.TaggedUserId, request.Time); return(response); }
public virtual DirectTweet MapModelToEntity( int tweetId, ApiDirectTweetServerRequestModel model ) { DirectTweet item = new DirectTweet(); item.SetProperties( tweetId, model.Content, model.Date, model.TaggedUserId, model.Time); return(item); }
public virtual async Task <CreateResponse <ApiDirectTweetServerResponseModel> > Create( ApiDirectTweetServerRequestModel model) { CreateResponse <ApiDirectTweetServerResponseModel> response = ValidationResponseFactory <ApiDirectTweetServerResponseModel> .CreateResponse(await this.DirectTweetModelValidator.ValidateCreateAsync(model)); if (response.Success) { DirectTweet record = this.DalDirectTweetMapper.MapModelToEntity(default(int), model); record = await this.DirectTweetRepository.Create(record); response.SetRecord(this.DalDirectTweetMapper.MapEntityToModel(record)); await this.mediator.Publish(new DirectTweetCreatedNotification(response.Record)); } return(response); }
public virtual async Task <UpdateResponse <ApiDirectTweetServerResponseModel> > Update( int tweetId, ApiDirectTweetServerRequestModel model) { var validationResult = await this.DirectTweetModelValidator.ValidateUpdateAsync(tweetId, model); if (validationResult.IsValid) { DirectTweet record = this.DalDirectTweetMapper.MapModelToEntity(tweetId, model); await this.DirectTweetRepository.Update(record); record = await this.DirectTweetRepository.Get(tweetId); ApiDirectTweetServerResponseModel apiModel = this.DalDirectTweetMapper.MapEntityToModel(record); await this.mediator.Publish(new DirectTweetUpdatedNotification(apiModel)); return(ValidationResponseFactory <ApiDirectTweetServerResponseModel> .UpdateResponse(apiModel)); } else { return(ValidationResponseFactory <ApiDirectTweetServerResponseModel> .UpdateResponse(validationResult)); } }