public JsonPatchDocument <ApiRetweetServerRequestModel> CreatePatch(ApiRetweetServerRequestModel model) { var patch = new JsonPatchDocument <ApiRetweetServerRequestModel>(); patch.Replace(x => x.Date, model.Date); patch.Replace(x => x.RetwitterUserId, model.RetwitterUserId); patch.Replace(x => x.Time, model.Time); patch.Replace(x => x.TweetTweetId, model.TweetTweetId); return(patch); }
public virtual ApiRetweetServerRequestModel MapServerResponseToRequest( ApiRetweetServerResponseModel response) { var request = new ApiRetweetServerRequestModel(); request.SetProperties( response.Date, response.RetwitterUserId, response.Time, response.TweetTweetId); return(request); }
public virtual ApiRetweetServerResponseModel MapServerRequestToResponse( int id, ApiRetweetServerRequestModel request) { var response = new ApiRetweetServerResponseModel(); response.SetProperties(id, request.Date, request.RetwitterUserId, request.Time, request.TweetTweetId); return(response); }
public void MapModelToEntity() { var mapper = new DALRetweetMapper(); ApiRetweetServerRequestModel model = new ApiRetweetServerRequestModel(); model.SetProperties(DateTime.Parse("1/1/1987 12:00:00 AM"), 1, TimeSpan.Parse("01:00:00"), 1); Retweet response = mapper.MapModelToEntity(1, model); response.Date.Should().Be(DateTime.Parse("1/1/1987 12:00:00 AM")); response.RetwitterUserId.Should().Be(1); response.Time.Should().Be(TimeSpan.Parse("01:00:00")); response.TweetTweetId.Should().Be(1); }
public virtual Retweet MapModelToEntity( int id, ApiRetweetServerRequestModel model ) { Retweet item = new Retweet(); item.SetProperties( id, model.Date, model.RetwitterUserId, model.Time, model.TweetTweetId); return(item); }
public virtual async Task <CreateResponse <ApiRetweetServerResponseModel> > Create( ApiRetweetServerRequestModel model) { CreateResponse <ApiRetweetServerResponseModel> response = ValidationResponseFactory <ApiRetweetServerResponseModel> .CreateResponse(await this.RetweetModelValidator.ValidateCreateAsync(model)); if (response.Success) { Retweet record = this.DalRetweetMapper.MapModelToEntity(default(int), model); record = await this.RetweetRepository.Create(record); response.SetRecord(this.DalRetweetMapper.MapEntityToModel(record)); await this.mediator.Publish(new RetweetCreatedNotification(response.Record)); } return(response); }
public virtual async Task <UpdateResponse <ApiRetweetServerResponseModel> > Update( int id, ApiRetweetServerRequestModel model) { var validationResult = await this.RetweetModelValidator.ValidateUpdateAsync(id, model); if (validationResult.IsValid) { Retweet record = this.DalRetweetMapper.MapModelToEntity(id, model); await this.RetweetRepository.Update(record); record = await this.RetweetRepository.Get(id); ApiRetweetServerResponseModel apiModel = this.DalRetweetMapper.MapEntityToModel(record); await this.mediator.Publish(new RetweetUpdatedNotification(apiModel)); return(ValidationResponseFactory <ApiRetweetServerResponseModel> .UpdateResponse(apiModel)); } else { return(ValidationResponseFactory <ApiRetweetServerResponseModel> .UpdateResponse(validationResult)); } }