예제 #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);
        }
예제 #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);
        }
예제 #4
0
        public virtual ApiSaleTicketsServerResponseModel MapServerRequestToResponse(
            int id,
            ApiSaleTicketsServerRequestModel request)
        {
            var response = new ApiSaleTicketsServerResponseModel();

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

            item.SetProperties(
                id,
                model.SaleId,
                model.TicketId);
            return(item);
        }
예제 #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);
        }
예제 #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));
            }
        }