Esempio n. 1
0
        public JsonPatchDocument <ApiSaleTicketsServerRequestModel> CreatePatch(ApiSaleTicketsServerRequestModel model)
        {
            var patch = new JsonPatchDocument <ApiSaleTicketsServerRequestModel>();

            patch.Replace(x => x.SaleId, model.SaleId);
            patch.Replace(x => x.TicketId, model.TicketId);
            return(patch);
        }
Esempio n. 2
0
        public virtual ApiSaleTicketsServerRequestModel MapServerResponseToRequest(
            ApiSaleTicketsServerResponseModel response)
        {
            var request = new ApiSaleTicketsServerRequestModel();

            request.SetProperties(
                response.SaleId,
                response.TicketId);
            return(request);
        }
        public void MapModelToEntity()
        {
            var mapper = new DALSaleTicketsMapper();
            ApiSaleTicketsServerRequestModel model = new ApiSaleTicketsServerRequestModel();

            model.SetProperties(1, 1);
            SaleTickets response = mapper.MapModelToEntity(1, model);

            response.SaleId.Should().Be(1);
            response.TicketId.Should().Be(1);
        }
Esempio n. 4
0
        public virtual ApiSaleTicketsServerResponseModel MapServerRequestToResponse(
            int id,
            ApiSaleTicketsServerRequestModel request)
        {
            var response = new ApiSaleTicketsServerResponseModel();

            response.SetProperties(id,
                                   request.SaleId,
                                   request.TicketId);
            return(response);
        }
Esempio n. 5
0
        public virtual SaleTickets MapModelToEntity(
            int id,
            ApiSaleTicketsServerRequestModel model
            )
        {
            SaleTickets item = new SaleTickets();

            item.SetProperties(
                id,
                model.SaleId,
                model.TicketId);
            return(item);
        }
Esempio n. 6
0
        public virtual async Task <CreateResponse <ApiSaleTicketsServerResponseModel> > Create(
            ApiSaleTicketsServerRequestModel model)
        {
            CreateResponse <ApiSaleTicketsServerResponseModel> response = ValidationResponseFactory <ApiSaleTicketsServerResponseModel> .CreateResponse(await this.SaleTicketsModelValidator.ValidateCreateAsync(model));

            if (response.Success)
            {
                SaleTickets record = this.DalSaleTicketsMapper.MapModelToEntity(default(int), model);
                record = await this.SaleTicketsRepository.Create(record);

                response.SetRecord(this.DalSaleTicketsMapper.MapEntityToModel(record));
                await this.mediator.Publish(new SaleTicketsCreatedNotification(response.Record));
            }

            return(response);
        }
Esempio n. 7
0
        public virtual async Task <UpdateResponse <ApiSaleTicketsServerResponseModel> > Update(
            int id,
            ApiSaleTicketsServerRequestModel model)
        {
            var validationResult = await this.SaleTicketsModelValidator.ValidateUpdateAsync(id, model);

            if (validationResult.IsValid)
            {
                SaleTickets record = this.DalSaleTicketsMapper.MapModelToEntity(id, model);
                await this.SaleTicketsRepository.Update(record);

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

                ApiSaleTicketsServerResponseModel apiModel = this.DalSaleTicketsMapper.MapEntityToModel(record);
                await this.mediator.Publish(new SaleTicketsUpdatedNotification(apiModel));

                return(ValidationResponseFactory <ApiSaleTicketsServerResponseModel> .UpdateResponse(apiModel));
            }
            else
            {
                return(ValidationResponseFactory <ApiSaleTicketsServerResponseModel> .UpdateResponse(validationResult));
            }
        }