public virtual async Task <CreateResponse <ApiTestAllFieldTypesNullableServerResponseModel> > Create(
            ApiTestAllFieldTypesNullableServerRequestModel model)
        {
            CreateResponse <ApiTestAllFieldTypesNullableServerResponseModel> response = ValidationResponseFactory <ApiTestAllFieldTypesNullableServerResponseModel> .CreateResponse(await this.TestAllFieldTypesNullableModelValidator.ValidateCreateAsync(model));

            if (response.Success)
            {
                TestAllFieldTypesNullable record = this.DalTestAllFieldTypesNullableMapper.MapModelToEntity(default(int), model);
                record = await this.TestAllFieldTypesNullableRepository.Create(record);

                response.SetRecord(this.DalTestAllFieldTypesNullableMapper.MapEntityToModel(record));
                await this.mediator.Publish(new TestAllFieldTypesNullableCreatedNotification(response.Record));
            }

            return(response);
        }
Beispiel #2
0
        public virtual TestAllFieldTypesNullable MapModelToEntity(
            int id,
            ApiTestAllFieldTypesNullableServerRequestModel model
            )
        {
            TestAllFieldTypesNullable item = new TestAllFieldTypesNullable();

            item.SetProperties(
                id,
                model.FieldBigInt,
                model.FieldBinary,
                model.FieldBit,
                model.FieldChar,
                model.FieldDate,
                model.FieldDateTime,
                model.FieldDateTime2,
                model.FieldDateTimeOffset,
                model.FieldDecimal,
                model.FieldFloat,
                model.FieldImage,
                model.FieldMoney,
                model.FieldNChar,
                model.FieldNText,
                model.FieldNumeric,
                model.FieldNVarchar,
                model.FieldReal,
                model.FieldSmallDateTime,
                model.FieldSmallInt,
                model.FieldSmallMoney,
                model.FieldText,
                model.FieldTime,
                model.FieldTimestamp,
                model.FieldTinyInt,
                model.FieldUniqueIdentifier,
                model.FieldVarBinary,
                model.FieldVarchar,
                model.FieldXML);
            return(item);
        }
        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));
            }
        }
Beispiel #4
0
        public void MapModelToEntity()
        {
            var mapper = new DALTestAllFieldTypesNullableMapper();
            ApiTestAllFieldTypesNullableServerRequestModel model = new ApiTestAllFieldTypesNullableServerRequestModel();

            model.SetProperties(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");
            TestAllFieldTypesNullable response = mapper.MapModelToEntity(1, model);

            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");
        }
Beispiel #5
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);
        }
Beispiel #6
0
        public JsonPatchDocument <ApiTestAllFieldTypesNullableServerRequestModel> CreatePatch(ApiTestAllFieldTypesNullableServerRequestModel model)
        {
            var patch = new JsonPatchDocument <ApiTestAllFieldTypesNullableServerRequestModel>();

            patch.Replace(x => x.FieldBigInt, model.FieldBigInt);
            patch.Replace(x => x.FieldBinary, model.FieldBinary);
            patch.Replace(x => x.FieldBit, model.FieldBit);
            patch.Replace(x => x.FieldChar, model.FieldChar);
            patch.Replace(x => x.FieldDate, model.FieldDate);
            patch.Replace(x => x.FieldDateTime, model.FieldDateTime);
            patch.Replace(x => x.FieldDateTime2, model.FieldDateTime2);
            patch.Replace(x => x.FieldDateTimeOffset, model.FieldDateTimeOffset);
            patch.Replace(x => x.FieldDecimal, model.FieldDecimal);
            patch.Replace(x => x.FieldFloat, model.FieldFloat);
            patch.Replace(x => x.FieldImage, model.FieldImage);
            patch.Replace(x => x.FieldMoney, model.FieldMoney);
            patch.Replace(x => x.FieldNChar, model.FieldNChar);
            patch.Replace(x => x.FieldNText, model.FieldNText);
            patch.Replace(x => x.FieldNumeric, model.FieldNumeric);
            patch.Replace(x => x.FieldNVarchar, model.FieldNVarchar);
            patch.Replace(x => x.FieldReal, model.FieldReal);
            patch.Replace(x => x.FieldSmallDateTime, model.FieldSmallDateTime);
            patch.Replace(x => x.FieldSmallInt, model.FieldSmallInt);
            patch.Replace(x => x.FieldSmallMoney, model.FieldSmallMoney);
            patch.Replace(x => x.FieldText, model.FieldText);
            patch.Replace(x => x.FieldTime, model.FieldTime);
            patch.Replace(x => x.FieldTimestamp, model.FieldTimestamp);
            patch.Replace(x => x.FieldTinyInt, model.FieldTinyInt);
            patch.Replace(x => x.FieldUniqueIdentifier, model.FieldUniqueIdentifier);
            patch.Replace(x => x.FieldVarBinary, model.FieldVarBinary);
            patch.Replace(x => x.FieldVarchar, model.FieldVarchar);
            patch.Replace(x => x.FieldXML, model.FieldXML);
            return(patch);
        }