Exemplo n.º 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);
        }
        public virtual ApiSaleClientRequestModel MapServerResponseToClientRequest(
            ApiSaleServerResponseModel response)
        {
            var request = new ApiSaleClientRequestModel();

            request.SetProperties(
                response.IpAddress,
                response.Notes,
                response.SaleDate,
                response.TransactionId);
            return(request);
        }
        public virtual ApiSaleServerResponseModel MapServerRequestToResponse(
            int id,
            ApiSaleServerRequestModel request)
        {
            var response = new ApiSaleServerResponseModel();

            response.SetProperties(id,
                                   request.IpAddress,
                                   request.Notes,
                                   request.SaleDate,
                                   request.TransactionId);
            return(response);
        }
Exemplo n.º 4
0
        public void MapEntityToModel()
        {
            var  mapper = new DALSaleMapper();
            Sale item   = new Sale();

            item.SetProperties(1, "A", "A", DateTime.Parse("1/1/1987 12:00:00 AM"), 1);
            ApiSaleServerResponseModel response = mapper.MapEntityToModel(item);

            response.Id.Should().Be(1);
            response.IpAddress.Should().Be("A");
            response.Notes.Should().Be("A");
            response.SaleDate.Should().Be(DateTime.Parse("1/1/1987 12:00:00 AM"));
            response.TransactionId.Should().Be(1);
        }
Exemplo n.º 5
0
        public virtual async Task <UpdateResponse <ApiSaleServerResponseModel> > Update(
            int id,
            ApiSaleServerRequestModel model)
        {
            var validationResult = await this.SaleModelValidator.ValidateUpdateAsync(id, model);

            if (validationResult.IsValid)
            {
                Sale record = this.DalSaleMapper.MapModelToEntity(id, model);
                await this.SaleRepository.Update(record);

                record = await this.SaleRepository.Get(id);

                ApiSaleServerResponseModel apiModel = this.DalSaleMapper.MapEntityToModel(record);
                await this.mediator.Publish(new SaleUpdatedNotification(apiModel));

                return(ValidationResponseFactory <ApiSaleServerResponseModel> .UpdateResponse(apiModel));
            }
            else
            {
                return(ValidationResponseFactory <ApiSaleServerResponseModel> .UpdateResponse(validationResult));
            }
        }
Exemplo n.º 6
0
        public virtual ApiSaleServerResponseModel MapEntityToModel(
            Sale item)
        {
            var model = new ApiSaleServerResponseModel();

            model.SetProperties(item.Id,
                                item.IpAddress,
                                item.Notes,
                                item.SaleDate,
                                item.TransactionId);
            if (item.TransactionIdNavigation != null)
            {
                var transactionIdModel = new ApiTransactionServerResponseModel();
                transactionIdModel.SetProperties(
                    item.TransactionIdNavigation.Id,
                    item.TransactionIdNavigation.Amount,
                    item.TransactionIdNavigation.GatewayConfirmationNumber,
                    item.TransactionIdNavigation.TransactionStatusId);

                model.SetTransactionIdNavigation(transactionIdModel);
            }

            return(model);
        }
Exemplo n.º 7
0
 public SaleUpdatedNotification(ApiSaleServerResponseModel record)
 {
     this.Record = record;
 }
Exemplo n.º 8
0
 public void SetSaleIdNavigation(ApiSaleServerResponseModel value)
 {
     this.SaleIdNavigation = value;
 }