2024-01-22 08:14:57 +00:00
|
|
|
package adminkindboxreqservice
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
param "git.gocasts.ir/ebhomengo/niki/param/admin/kind_box_req"
|
|
|
|
richerror "git.gocasts.ir/ebhomengo/niki/pkg/rich_error"
|
|
|
|
)
|
|
|
|
|
|
|
|
func (s Service) Accept(ctx context.Context, req param.KindBoxReqAcceptRequest) (param.KindBoxReqAcceptResponse, error) {
|
|
|
|
const op = "adminkindboxreqservice.Accept"
|
2024-01-22 10:43:16 +00:00
|
|
|
err := s.repo.AcceptKindBoxReq(ctx, req.ID, req.CountAccepted)
|
2024-01-22 08:14:57 +00:00
|
|
|
if err != nil {
|
|
|
|
return param.KindBoxReqAcceptResponse{}, richerror.New(op).WithErr(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
// fire new event to create a kind-box.
|
|
|
|
//get kind box req
|
|
|
|
|
|
|
|
kindBoxReq, gErr := s.repo.FindByID(ctx, req.ID)
|
|
|
|
if gErr != nil {
|
|
|
|
return param.KindBoxReqAcceptResponse{}, richerror.New(op).WithErr(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
return param.KindBoxReqAcceptResponse{
|
|
|
|
ID: kindBoxReq.ID,
|
|
|
|
KindBoxType: kindBoxReq.KindBoxType,
|
|
|
|
CountRequested: kindBoxReq.CountRequested,
|
|
|
|
CountAccepted: kindBoxReq.CountAccepted,
|
|
|
|
BenefactorID: kindBoxReq.BenefactorID,
|
|
|
|
Status: kindBoxReq.Status,
|
|
|
|
Description: kindBoxReq.Description,
|
|
|
|
ReferDate: kindBoxReq.ReferDate,
|
|
|
|
AddressID: kindBoxReq.AddressID,
|
|
|
|
}, nil
|
|
|
|
}
|