public async Task <IActionResult> GetRentedPlaceById(string id) { int ID = Convert.ToInt32(id); var entity = await RentedPlaceDTO.ToEntity(ID, _context); if (entity == null) { return(NotFound()); } return(Ok(entity)); }
public async Task <IActionResult> Delete(int id) { var entity = await RentedPlaceDTO.ToEntity(id, _context); if (entity == null) { return(NotFound()); } _context.RentedPlaces.Remove(entity); await _context.SaveChangesAsync(); return(NoContent()); }
public async Task <IActionResult> Put(RentedPlaceDTO dto) { var entity = await RentedPlaceDTO.ToEntity(dto, _context); if (entity == null) { return(NotFound()); } _context.Entry(entity).State = EntityState.Modified; await _context.SaveChangesAsync(); return(CreatedAtAction("Get", new { }, dto)); }
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)); }