public async Task <IActionResult> Add([FromForm] AnnoucementForCreateDto annoucementDto) // id?? { var userId = GetUserIdentifierFromClaims(); AnnoucementForViewDto annoucement = await _service.CreateNewAnnoucement(annoucementDto, userId); return(CreatedAtAction("GetById", new { id = annoucement.Id }, annoucement)); }
public async Task <IActionResult> GetById([FromRoute] int id) { AnnoucementForViewDto annoucementDto = await _service.GetAnnoucementById(id); if (annoucementDto == null) { return(NotFound($"No annoucement with id: {id}")); } return(Ok(annoucementDto)); }
public async Task <IActionResult> Update([FromForm] AnnoucementForUpdateDto annoucementDto) { var userId = GetUserIdentifierFromClaims(); AnnoucementForViewDto annoucement = await _service.UpdateAnnoucement(annoucementDto, userId); if (annoucement == null) { throw Exception($"Could not update annoucement with id {annoucementDto.AnnoucementId}"); } return(CreatedAtAction("GetById", new { id = annoucement.Id }, annoucement)); }