public JsonPatchDocument <ApiFollowingServerRequestModel> CreatePatch(ApiFollowingServerRequestModel model) { var patch = new JsonPatchDocument <ApiFollowingServerRequestModel>(); patch.Replace(x => x.DateFollowed, model.DateFollowed); patch.Replace(x => x.Muted, model.Muted); return(patch); }
public virtual ApiFollowingServerRequestModel MapServerResponseToRequest( ApiFollowingServerResponseModel response) { var request = new ApiFollowingServerRequestModel(); request.SetProperties( response.DateFollowed, response.Muted); return(request); }
public virtual ApiFollowingServerResponseModel MapServerRequestToResponse( int userId, ApiFollowingServerRequestModel request) { var response = new ApiFollowingServerResponseModel(); response.SetProperties(userId, request.DateFollowed, request.Muted); return(response); }
public void MapModelToEntity() { var mapper = new DALFollowingMapper(); ApiFollowingServerRequestModel model = new ApiFollowingServerRequestModel(); model.SetProperties(DateTime.Parse("1/1/1987 12:00:00 AM"), "A"); Following response = mapper.MapModelToEntity(1, model); response.DateFollowed.Should().Be(DateTime.Parse("1/1/1987 12:00:00 AM")); response.Muted.Should().Be("A"); }
public virtual Following MapModelToEntity( int userId, ApiFollowingServerRequestModel model ) { Following item = new Following(); item.SetProperties( userId, model.DateFollowed, model.Muted); return(item); }
public virtual async Task <CreateResponse <ApiFollowingServerResponseModel> > Create( ApiFollowingServerRequestModel model) { CreateResponse <ApiFollowingServerResponseModel> response = ValidationResponseFactory <ApiFollowingServerResponseModel> .CreateResponse(await this.FollowingModelValidator.ValidateCreateAsync(model)); if (response.Success) { Following record = this.DalFollowingMapper.MapModelToEntity(default(int), model); record = await this.FollowingRepository.Create(record); response.SetRecord(this.DalFollowingMapper.MapEntityToModel(record)); await this.mediator.Publish(new FollowingCreatedNotification(response.Record)); } return(response); }
public virtual async Task <UpdateResponse <ApiFollowingServerResponseModel> > Update( int userId, ApiFollowingServerRequestModel model) { var validationResult = await this.FollowingModelValidator.ValidateUpdateAsync(userId, model); if (validationResult.IsValid) { Following record = this.DalFollowingMapper.MapModelToEntity(userId, model); await this.FollowingRepository.Update(record); record = await this.FollowingRepository.Get(userId); ApiFollowingServerResponseModel apiModel = this.DalFollowingMapper.MapEntityToModel(record); await this.mediator.Publish(new FollowingUpdatedNotification(apiModel)); return(ValidationResponseFactory <ApiFollowingServerResponseModel> .UpdateResponse(apiModel)); } else { return(ValidationResponseFactory <ApiFollowingServerResponseModel> .UpdateResponse(validationResult)); } }