public async Task <ActionResult <IEnumerable <RentedPlaceDTO> > > Get() { return(await _context.RentedPlaces .OrderBy(i => i.RentedName) .Select(i => RentedPlaceDTO.FromEntity(i)) .ToListAsync()); }
public async Task <ActionResult <RentedPlaceDTO> > Post(RentedPlaceDTO dto) { var entity = await RentedPlaceDTO.ToEntity(dto, _context); if (entity == null) { return(NotFound()); } await _context.RentedPlaces.AddAsync(entity); await _context.SaveChangesAsync(); var contractDto = RentedPlaceDTO.FromEntity(entity); return(CreatedAtAction("Get", new { }, contractDto)); }