Exemple #1
0
func (this *partnerService) SavePartner(partnerId int, v *partner.ValuePartner) (int, error) {
	var pt partner.IPartner
	var err error
	var isCreate bool

	v.Id = partnerId

	if partnerId > 0 {
		pt, _ = this._partnerRep.GetPartner(partnerId)
		if pt == nil {
			err = errors.New("no such partner")
		} else {
			err = pt.SetValue(v)
		}
	} else {
		isCreate = true
		pt, err = this._partnerRep.CreatePartner(v)
	}

	if err != nil {
		return 0, err
	}

	partnerId, err = pt.Save()

	if isCreate {
		this.initializePartner(partnerId)
	}

	return partnerId, err
}
Exemple #2
0
func (this *partnerService) SavePartner(partnerId int, v *partner.ValuePartner) (int, error) {
	var pt partner.IPartner
	var err error
	v.Id = partnerId

	if partnerId > 0 {
		pt, _ = this._partnerRep.GetPartner(partnerId)
		if pt == nil {
			err = errors.New("no such partner")
		} else {
			err = pt.SetValue(v)
		}
	} else {
		pt, err = this._partnerRep.CreatePartner(v)
	}

	if err != nil {
		return 0, err
	}

	return pt.Save()
}