Skip to content

Commit db6e5a6

Browse files
author
Onur Menal
committed
UpdateComment service
1 parent 3ce0da8 commit db6e5a6

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

internal/comment/comment.go

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ type Store interface {
2222
GetComment(context.Context, string) (Comment, error)
2323
PostComment(context.Context, Comment) (Comment, error)
2424
DeleteComment(context.Context, string) error
25+
UpdateComment(context.Context, string, Comment) (Comment, error)
2526
}
2627

2728
type Service struct {
@@ -44,8 +45,14 @@ func (s *Service) GetComment(ctx context.Context, id string) (Comment, error) {
4445
return cmt, nil
4546
}
4647

47-
func (s *Service) UpdateComment(ctx context.Context, cmt Comment) error {
48-
return ErrorNotImplemented
48+
func (s *Service) UpdateComment(ctx context.Context, id string, cmt Comment) (Comment, error) {
49+
fmt.Println("updating a comment")
50+
cmt, err := s.Store.UpdateComment(ctx, id, cmt)
51+
if err != nil {
52+
return Comment{}, ErrorMessage
53+
}
54+
55+
return cmt, nil
4956
}
5057

5158
func (s *Service) DeleteCommment(ctx context.Context, id string) error {

0 commit comments

Comments
 (0)