import { Body, Controller, Get, Param, Post, Put } from '@nestjs/common';
import { PrismaService } from '../prisma/prisma.service';

@Controller('contact')
export class ContactController {
  constructor(private prisma: PrismaService){}
  @Post()
  async create(@Body() body:any){
    const { name, email, subject, message } = body;
    return this.prisma.contactMessage.create({ data:{ name, email, subject, message } });
  }
  @Get(':id')
  get(@Param('id') id:string){ return this.prisma.contactMessage.findUnique({ where:{ id } }); }
  @Put(':id')
  update(@Param('id') id:string, @Body() body:any){ return this.prisma.contactMessage.update({ where:{ id }, data: body }); }
}
