2024-06-08 14:25:24 +00:00
|
|
|
package benefactoraddressservice
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
|
|
|
|
param "git.gocasts.ir/ebhomengo/niki/param/benefactor/address"
|
|
|
|
richerror "git.gocasts.ir/ebhomengo/niki/pkg/rich_error"
|
|
|
|
)
|
|
|
|
|
2024-08-01 10:20:18 +00:00
|
|
|
func (s Service) Delete(ctx context.Context, req param.DeleteAddressRequest) (param.DeleteAddressResponse, error) {
|
2024-06-08 14:25:24 +00:00
|
|
|
const op = "benefactoraddressservice.Delete"
|
2024-08-01 10:20:18 +00:00
|
|
|
if fieldErrors, vErr := s.vld.ValidateDeleteRequest(ctx, req); vErr != nil {
|
|
|
|
return param.DeleteAddressResponse{FieldErrors: fieldErrors}, richerror.New(op).WithErr(vErr)
|
|
|
|
}
|
2024-06-08 14:25:24 +00:00
|
|
|
err := s.repo.DeleteBenefactorAddress(ctx, req.AddressID, req.BenefactorID)
|
|
|
|
if err != nil {
|
2024-08-01 10:20:18 +00:00
|
|
|
return param.DeleteAddressResponse{}, richerror.New(op).WithErr(err)
|
2024-06-08 14:25:24 +00:00
|
|
|
}
|
|
|
|
|
2024-08-01 10:20:18 +00:00
|
|
|
return param.DeleteAddressResponse{}, nil
|
2024-06-08 14:25:24 +00:00
|
|
|
}
|