Beispiel #1
0
        public async Task <bool> Create(HouseForCreateDto house)
        {
            var houseToAdd = _mapper.Map <House>(house);

            if (houseToAdd != null)
            {
                await _db.Houses.AddAsync(houseToAdd);

                await _db.SaveChangesAsync();

                return(true);
            }

            return(false);
        }
Beispiel #2
0
        public async Task <IActionResult> Add(HouseForCreateDto house)
        {
            if (house == null)
            {
                return(BadRequest("Add object is null"));
            }

            var result = await _houseService.Create(house);

            if (result)
            {
                return(Ok("Created successfully"));
            }
            else
            {
                return(BadRequest("Failed to Create"));
            }
        }