コード例 #1
0
        public async Task <int> CreateHouseRentAsync(HouseRent houseRent, CancellationToken ct)
        {
            try
            {
                using var context = contextFactory.GetAdvContext();
                await context.HouseRents.AddAsync(houseRent, ct).ConfigureAwait(false);

                var result = await context.SaveChangesAsync(ct).ConfigureAwait(false);

                return(result > 0 ? houseRent.Id : throw new BadCreateException("Мы не смогли создать объявление"));
            }
            catch (Exception e)
            {
                Debug.WriteLine(e);
                throw;
            }
        }
コード例 #2
0
        private static void HouseRentChoiceAdapterPropertiesWork()
        {
            var re = new HouseRent();

            Assert.Null(re.Item);
            Assert.Null(re.ConstructionYear);
            re.ConstructionYear = 1900;
            Assert.Equal(1900, re.Item);
            Assert.Equal(1900, re.ConstructionYear);
            re.ConstructionYear = null;
            Assert.Null(re.ConstructionYear);
            Assert.True(re.ConstructionYearUnknown);
            re.ConstructionYearUnknown = true;
            Assert.IsType <bool>(re.Item);
            Assert.True((bool)re.Item);
            Assert.Null(re.ConstructionYear);

            Assert.Null(re.Item1);
            Assert.Null(re.HeatingType);
            Assert.Null(re.HeatingTypeEnev2014);
            re.HeatingType = HeatingType.STOVE_HEATING;
            Assert.IsType <HeatingType>(re.Item1);
            Assert.Equal(HeatingType.STOVE_HEATING, re.Item1);
            re.HeatingTypeEnev2014 = HeatingTypeEnev2014.FLOOR_HEATING;
            Assert.IsType <HeatingTypeEnev2014>(re.Item1);
            Assert.Equal(HeatingTypeEnev2014.FLOOR_HEATING, re.Item1);
            Assert.Null(re.HeatingType);

            Assert.Null(re.Item2);
            Assert.Null(re.FiringTypes);
            Assert.Null(re.EnergySourcesEnev2014);
            re.FiringTypes = new FiringTypes();
            Assert.IsType <FiringTypes>(re.Item2);
            Assert.Null(re.EnergySourcesEnev2014);
            re.EnergySourcesEnev2014 = new EnergySourcesEnev2014();
            Assert.IsType <EnergySourcesEnev2014>(re.Item2);
            Assert.Null(re.FiringTypes);
        }
コード例 #3
0
        private static void HouseRentChoiceAdapterPropertiesWork()
        {
            var re = new HouseRent();

            Assert.Null(re.Item);
            Assert.Null(re.ConstructionYear);
            re.ConstructionYear = 1900;
            Assert.Equal(1900, re.Item);
            Assert.Equal(1900, re.ConstructionYear);
            re.ConstructionYear = null;
            Assert.Null(re.ConstructionYear);
            Assert.True(re.ConstructionYearUnknown);
            re.ConstructionYearUnknown = true;
            Assert.IsType<bool>(re.Item);
            Assert.True((bool)re.Item);
            Assert.Null(re.ConstructionYear);

            Assert.Null(re.Item1);
            Assert.Null(re.HeatingType);
            Assert.Null(re.HeatingTypeEnev2014);
            re.HeatingType = HeatingType.STOVE_HEATING;
            Assert.IsType<HeatingType>(re.Item1);
            Assert.Equal(HeatingType.STOVE_HEATING, re.Item1);
            re.HeatingTypeEnev2014 = HeatingTypeEnev2014.FLOOR_HEATING;
            Assert.IsType<HeatingTypeEnev2014>(re.Item1);
            Assert.Equal(HeatingTypeEnev2014.FLOOR_HEATING, re.Item1);
            Assert.Null(re.HeatingType);

            Assert.Null(re.Item2);
            Assert.Null(re.FiringTypes);
            Assert.Null(re.EnergySourcesEnev2014);
            re.FiringTypes = new FiringTypes();
            Assert.IsType<FiringTypes>(re.Item2);
            Assert.Null(re.EnergySourcesEnev2014);
            re.EnergySourcesEnev2014 = new EnergySourcesEnev2014();
            Assert.IsType<EnergySourcesEnev2014>(re.Item2);
            Assert.Null(re.FiringTypes);
        }
コード例 #4
0
        private static void HouseRentChoiceAdapterPropertiesWork()
        {
            var re = new HouseRent();

            Assert.Null(re.Item);
            Assert.Null(re.ConstructionYear);
            re.ConstructionYear = 1900;
            Assert.Equal(1900, re.Item);
            Assert.Equal(1900, re.ConstructionYear);
            re.ConstructionYear = null;
            Assert.Null(re.ConstructionYear);
            Assert.True(re.ConstructionYearUnknown);
            re.ConstructionYearUnknown = true;
            Assert.IsType<bool>(re.Item);
            Assert.True((bool)re.Item);
            Assert.Null(re.ConstructionYear);
        }