public JsonPatchDocument <ApiTicketServerRequestModel> CreatePatch(ApiTicketServerRequestModel model) { var patch = new JsonPatchDocument <ApiTicketServerRequestModel>(); patch.Replace(x => x.PublicId, model.PublicId); patch.Replace(x => x.TicketStatusId, model.TicketStatusId); return(patch); }
public virtual ApiTicketServerRequestModel MapServerResponseToRequest( ApiTicketServerResponseModel response) { var request = new ApiTicketServerRequestModel(); request.SetProperties( response.PublicId, response.TicketStatusId); return(request); }
public void MapModelToEntity() { var mapper = new DALTicketMapper(); ApiTicketServerRequestModel model = new ApiTicketServerRequestModel(); model.SetProperties("A", 1); Ticket response = mapper.MapModelToEntity(1, model); response.PublicId.Should().Be("A"); response.TicketStatusId.Should().Be(1); }
public virtual ApiTicketServerResponseModel MapServerRequestToResponse( int id, ApiTicketServerRequestModel request) { var response = new ApiTicketServerResponseModel(); response.SetProperties(id, request.PublicId, request.TicketStatusId); return(response); }
public virtual Ticket MapModelToEntity( int id, ApiTicketServerRequestModel model ) { Ticket item = new Ticket(); item.SetProperties( id, model.PublicId, model.TicketStatusId); return(item); }
public virtual async Task <CreateResponse <ApiTicketServerResponseModel> > Create( ApiTicketServerRequestModel model) { CreateResponse <ApiTicketServerResponseModel> response = ValidationResponseFactory <ApiTicketServerResponseModel> .CreateResponse(await this.TicketModelValidator.ValidateCreateAsync(model)); if (response.Success) { Ticket record = this.DalTicketMapper.MapModelToEntity(default(int), model); record = await this.TicketRepository.Create(record); response.SetRecord(this.DalTicketMapper.MapEntityToModel(record)); await this.mediator.Publish(new TicketCreatedNotification(response.Record)); } return(response); }
public virtual async Task <UpdateResponse <ApiTicketServerResponseModel> > Update( int id, ApiTicketServerRequestModel model) { var validationResult = await this.TicketModelValidator.ValidateUpdateAsync(id, model); if (validationResult.IsValid) { Ticket record = this.DalTicketMapper.MapModelToEntity(id, model); await this.TicketRepository.Update(record); record = await this.TicketRepository.Get(id); ApiTicketServerResponseModel apiModel = this.DalTicketMapper.MapEntityToModel(record); await this.mediator.Publish(new TicketUpdatedNotification(apiModel)); return(ValidationResponseFactory <ApiTicketServerResponseModel> .UpdateResponse(apiModel)); } else { return(ValidationResponseFactory <ApiTicketServerResponseModel> .UpdateResponse(validationResult)); } }