コード例 #1
0
        public async Task <ActionResult> Post([FromBody] HouseITO property)
        {
            if (property != null)
            {
                var houseDB      = _mapper.Map <House>(property);
                var houseAddress = _mapper.Map <IEnumerable <PropertyAddresses> >(property.Addresses);
                var housePrice   = _mapper.Map <PropertyPrice>(property.Price);
                //var housePhotos = _mapper.Map<IEnumerable<PropertyPhotos>>(property.Photos);

                await _work.Houses.Add(houseDB);

                await _work.PropertyPrice.Add(housePrice);

                await _work.PropertyAddress.AddRange(houseAddress);

                //await _work.PropertyPhotos.AddImages(housePhotos);


                await _work.Complete();

                _work.Dispose();
                var houseDTO = _mapper.Map <HouseDTO>(houseDB);

                return(new CreatedAtRouteResult("search-house-by-id", new { id = houseDB.Id }, houseDTO));
            }
            return(BadRequest());
        }
コード例 #2
0
        public async Task <ActionResult> Post([FromBody] BuildingSiteITO buildingSite)
        {
            if (buildingSite != null)
            {
                var buildingSitePrice   = _mapper.Map <PropertyPrice>(buildingSite.Price);
                var buildingSiteAddress = _mapper.Map <IEnumerable <PropertyAddresses> >(buildingSite.Addresses);
                //var buildingSitePhotos = _mapper.Map<IEnumerable<PropertyPhotos>>(buildingSite.Photos);
                var buildingSiteDB = _mapper.Map <BuildingSite>(buildingSite);

                await _work.BuildingSites.Add(buildingSiteDB);

                await _work.PropertyAddress.AddRange(buildingSiteAddress);

                await _work.PropertyPrice.Add(buildingSitePrice);

                //await _work.PropertyPhotos.AddImages(buildingSitePhotos);

                await _work.Complete();

                _work.Dispose();

                var buildingSiteDTO = _mapper.Map <BuildingSiteDTO>(buildingSiteDB);

                return(new CreatedAtRouteResult("search-buildingSite-by-id", new { id = buildingSiteDB.Id }, buildingSiteDTO));
            }
            return(BadRequest());
        }