コード例 #1
0
        public virtual ApiSaleTicketsServerResponseModel MapEntityToModel(
            SaleTickets item)
        {
            var model = new ApiSaleTicketsServerResponseModel();

            model.SetProperties(item.Id,
                                item.SaleId,
                                item.TicketId);
            if (item.SaleIdNavigation != null)
            {
                var saleIdModel = new ApiSaleServerResponseModel();
                saleIdModel.SetProperties(
                    item.SaleIdNavigation.Id,
                    item.SaleIdNavigation.IpAddress,
                    item.SaleIdNavigation.Notes,
                    item.SaleIdNavigation.SaleDate,
                    item.SaleIdNavigation.TransactionId);

                model.SetSaleIdNavigation(saleIdModel);
            }

            if (item.TicketIdNavigation != null)
            {
                var ticketIdModel = new ApiTicketServerResponseModel();
                ticketIdModel.SetProperties(
                    item.TicketIdNavigation.Id,
                    item.TicketIdNavigation.PublicId,
                    item.TicketIdNavigation.TicketStatusId);

                model.SetTicketIdNavigation(ticketIdModel);
            }

            return(model);
        }
コード例 #2
0
        public virtual ApiTicketClientRequestModel MapServerResponseToClientRequest(
            ApiTicketServerResponseModel response)
        {
            var request = new ApiTicketClientRequestModel();

            request.SetProperties(
                response.PublicId,
                response.TicketStatusId);
            return(request);
        }
コード例 #3
0
        public virtual ApiTicketServerResponseModel MapServerRequestToResponse(
            int id,
            ApiTicketServerRequestModel request)
        {
            var response = new ApiTicketServerResponseModel();

            response.SetProperties(id,
                                   request.PublicId,
                                   request.TicketStatusId);
            return(response);
        }
コード例 #4
0
        public void MapEntityToModel()
        {
            var    mapper = new DALTicketMapper();
            Ticket item   = new Ticket();

            item.SetProperties(1, "A", 1);
            ApiTicketServerResponseModel response = mapper.MapEntityToModel(item);

            response.Id.Should().Be(1);
            response.PublicId.Should().Be("A");
            response.TicketStatusId.Should().Be(1);
        }
コード例 #5
0
        public virtual ApiTicketServerResponseModel MapEntityToModel(
            Ticket item)
        {
            var model = new ApiTicketServerResponseModel();

            model.SetProperties(item.Id,
                                item.PublicId,
                                item.TicketStatusId);
            if (item.TicketStatusIdNavigation != null)
            {
                var ticketStatusIdModel = new ApiTicketStatusServerResponseModel();
                ticketStatusIdModel.SetProperties(
                    item.TicketStatusIdNavigation.Id,
                    item.TicketStatusIdNavigation.Name);

                model.SetTicketStatusIdNavigation(ticketStatusIdModel);
            }

            return(model);
        }
コード例 #6
0
        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));
            }
        }
コード例 #7
0
 public void SetTicketIdNavigation(ApiTicketServerResponseModel value)
 {
     this.TicketIdNavigation = value;
 }
コード例 #8
0
ファイル: TicketHandler.cs プロジェクト: codenesium/samples
 public TicketUpdatedNotification(ApiTicketServerResponseModel record)
 {
     this.Record = record;
 }