示例#1
0
        public IActionResult Get(int id)
        {
            var entity = houseRepository.Get(id);
            var result = mapper.Map <HouseDto>(entity);

            return(Ok(entity));
        }
示例#2
0
        public async Task <ActionResult <CreatePersonView> > CreatePersonRequest(
            CancellationToken cancellationToken,
            [FromRoute] Guid houseId,
            [FromBody] CreatePersonBinding binding)
        {
            try
            {
                var house = await _houseRepository.Get(houseId, cancellationToken);

                if (house == null)
                {
                    return(NotFound($"House not found: {houseId}"));
                }

                var person = new CreatePersonRequest(Guid.NewGuid(), binding.Name, binding.Surname, binding.Login, binding.Password, house);

                await _createPersonRepository.Create(person, cancellationToken);

                return(Ok(new CreatePersonView
                {
                    Id = person.Id,
                    Name = person.Name,
                    Surname = person.Surname,
                    Login = person.Login
                }));
            }
            catch (InvalidOperationException exception)
            {
                return(Conflict(exception.Message));
            }
        }
示例#3
0
 public House Get(int id)
 {
     return(_houseRepository.Get(id));
 }
 public HouseDto Get(Guid id)
 {
     return(_mapper.Map <HouseDto>(_houseRepository.Get(id)));
 }