Exemplo n.º 1
0
        public void MapEntityToModel()
        {
            var mapper = new DALTestAllFieldTypesNullableMapper();
            TestAllFieldTypesNullable item = new TestAllFieldTypesNullable();

            item.SetProperties(1, 1, BitConverter.GetBytes(1), true, "A", DateTime.Parse("1/1/1987 12:00:00 AM"), DateTime.Parse("1/1/1987 12:00:00 AM"), DateTime.Parse("1/1/1987 12:00:00 AM"), DateTimeOffset.Parse("1/1/1987 12:00:00 AM"), 1m, 1, BitConverter.GetBytes(1), 1m, "A", "A", 1m, "A", 1m, DateTime.Parse("1/1/1987 12:00:00 AM"), 1, 1m, "A", TimeSpan.Parse("01:00:00"), BitConverter.GetBytes(1), 1, Guid.Parse("8420cdcf-d595-ef65-66e7-dff9f98764da"), BitConverter.GetBytes(1), "A", "A");
            ApiTestAllFieldTypesNullableServerResponseModel response = mapper.MapEntityToModel(item);

            response.FieldBigInt.Should().Be(1);
            response.FieldBinary.Should().BeEquivalentTo(BitConverter.GetBytes(1));
            response.FieldBit.Should().Be(true);
            response.FieldChar.Should().Be("A");
            response.FieldDate.Should().Be(DateTime.Parse("1/1/1987 12:00:00 AM"));
            response.FieldDateTime.Should().Be(DateTime.Parse("1/1/1987 12:00:00 AM"));
            response.FieldDateTime2.Should().Be(DateTime.Parse("1/1/1987 12:00:00 AM"));
            response.FieldDateTimeOffset.Should().Be(DateTimeOffset.Parse("1/1/1987 12:00:00 AM"));
            response.FieldDecimal.Should().Be(1m);
            response.FieldFloat.Should().Be(1);
            response.FieldImage.Should().BeEquivalentTo(BitConverter.GetBytes(1));
            response.FieldMoney.Should().Be(1m);
            response.FieldNChar.Should().Be("A");
            response.FieldNText.Should().Be("A");
            response.FieldNumeric.Should().Be(1m);
            response.FieldNVarchar.Should().Be("A");
            response.FieldReal.Should().Be(1m);
            response.FieldSmallDateTime.Should().Be(DateTime.Parse("1/1/1987 12:00:00 AM"));
            response.FieldSmallInt.Should().Be(1);
            response.FieldSmallMoney.Should().Be(1m);
            response.FieldText.Should().Be("A");
            response.FieldTime.Should().Be(TimeSpan.Parse("01:00:00"));
            response.FieldTimestamp.Should().BeEquivalentTo(BitConverter.GetBytes(1));
            response.FieldTinyInt.Should().Be(1);
            response.FieldUniqueIdentifier.Should().Be(Guid.Parse("8420cdcf-d595-ef65-66e7-dff9f98764da"));
            response.FieldVarBinary.Should().BeEquivalentTo(BitConverter.GetBytes(1));
            response.FieldVarchar.Should().Be("A");
            response.FieldXML.Should().Be("A");
            response.Id.Should().Be(1);
        }
        public virtual async Task <UpdateResponse <ApiTestAllFieldTypesNullableServerResponseModel> > Update(
            int id,
            ApiTestAllFieldTypesNullableServerRequestModel model)
        {
            var validationResult = await this.TestAllFieldTypesNullableModelValidator.ValidateUpdateAsync(id, model);

            if (validationResult.IsValid)
            {
                TestAllFieldTypesNullable record = this.DalTestAllFieldTypesNullableMapper.MapModelToEntity(id, model);
                await this.TestAllFieldTypesNullableRepository.Update(record);

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

                ApiTestAllFieldTypesNullableServerResponseModel apiModel = this.DalTestAllFieldTypesNullableMapper.MapEntityToModel(record);
                await this.mediator.Publish(new TestAllFieldTypesNullableUpdatedNotification(apiModel));

                return(ValidationResponseFactory <ApiTestAllFieldTypesNullableServerResponseModel> .UpdateResponse(apiModel));
            }
            else
            {
                return(ValidationResponseFactory <ApiTestAllFieldTypesNullableServerResponseModel> .UpdateResponse(validationResult));
            }
        }
Exemplo n.º 3
0
        public virtual ApiTestAllFieldTypesNullableServerResponseModel MapServerRequestToResponse(
            int id,
            ApiTestAllFieldTypesNullableServerRequestModel request)
        {
            var response = new ApiTestAllFieldTypesNullableServerResponseModel();

            response.SetProperties(id,
                                   request.FieldBigInt,
                                   request.FieldBinary,
                                   request.FieldBit,
                                   request.FieldChar,
                                   request.FieldDate,
                                   request.FieldDateTime,
                                   request.FieldDateTime2,
                                   request.FieldDateTimeOffset,
                                   request.FieldDecimal,
                                   request.FieldFloat,
                                   request.FieldImage,
                                   request.FieldMoney,
                                   request.FieldNChar,
                                   request.FieldNText,
                                   request.FieldNumeric,
                                   request.FieldNVarchar,
                                   request.FieldReal,
                                   request.FieldSmallDateTime,
                                   request.FieldSmallInt,
                                   request.FieldSmallMoney,
                                   request.FieldText,
                                   request.FieldTime,
                                   request.FieldTimestamp,
                                   request.FieldTinyInt,
                                   request.FieldUniqueIdentifier,
                                   request.FieldVarBinary,
                                   request.FieldVarchar,
                                   request.FieldXML);
            return(response);
        }
Exemplo n.º 4
0
        public virtual ApiTestAllFieldTypesNullableServerResponseModel MapEntityToModel(
            TestAllFieldTypesNullable item)
        {
            var model = new ApiTestAllFieldTypesNullableServerResponseModel();

            model.SetProperties(item.Id,
                                item.FieldBigInt,
                                item.FieldBinary,
                                item.FieldBit,
                                item.FieldChar,
                                item.FieldDate,
                                item.FieldDateTime,
                                item.FieldDateTime2,
                                item.FieldDateTimeOffset,
                                item.FieldDecimal,
                                item.FieldFloat,
                                item.FieldImage,
                                item.FieldMoney,
                                item.FieldNChar,
                                item.FieldNText,
                                item.FieldNumeric,
                                item.FieldNVarchar,
                                item.FieldReal,
                                item.FieldSmallDateTime,
                                item.FieldSmallInt,
                                item.FieldSmallMoney,
                                item.FieldText,
                                item.FieldTime,
                                item.FieldTimestamp,
                                item.FieldTinyInt,
                                item.FieldUniqueIdentifier,
                                item.FieldVarBinary,
                                item.FieldVarchar,
                                item.FieldXML);

            return(model);
        }
Exemplo n.º 5
0
 public TestAllFieldTypesNullableUpdatedNotification(ApiTestAllFieldTypesNullableServerResponseModel record)
 {
     this.Record = record;
 }