stock request table created
This commit is contained in:
@@ -21,6 +21,7 @@ type TenantRepository interface {
|
||||
GetTenantPricing(tid, aid int) (*models.Tenantpricing, error)
|
||||
UpdateLocation(input models.Tenantlocations) error
|
||||
CreateLocation(data models.Tenantlocations) error
|
||||
DeleteLocation(locationid int, tenantid int) error
|
||||
GetStaffs(tid int) ([]models.StaffInfo, error)
|
||||
CreateStaff(user models.User) error
|
||||
UpdateStaff(user models.User) error
|
||||
@@ -290,52 +291,10 @@ func (r *tenantRepository) UpdateLocation(input models.Tenantlocations) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (r *tenantRepository) CreateLocation(data models.Tenantlocations) error {
|
||||
var cust models.Customers
|
||||
var tcust models.Tenantcustomers
|
||||
var custloc models.Customerlocations
|
||||
|
||||
func (r *tenantRepository) DeleteLocation(locationid int, tenantid int) error {
|
||||
tx := r.db.Begin()
|
||||
|
||||
if err := tx.Create(&data).Error; err != nil {
|
||||
tx.Rollback()
|
||||
return err
|
||||
}
|
||||
|
||||
cust.Firstname = data.Locationname
|
||||
cust.Email = data.Email
|
||||
cust.Contactno = data.Contactno
|
||||
cust.Address = data.Address
|
||||
cust.Suburb = data.Suburb
|
||||
cust.City = data.City
|
||||
cust.State = data.State
|
||||
cust.Postcode = data.Postcode
|
||||
cust.Applocationid = data.Applocationid
|
||||
cust.Latitude = data.Latitude
|
||||
cust.Longitude = data.Longitude
|
||||
cust.Primaryaddress = 0
|
||||
|
||||
if err := tx.Table("customers").Create(&cust).Error; err != nil {
|
||||
tx.Rollback()
|
||||
return err
|
||||
}
|
||||
|
||||
if err := copier.Copy(&custloc, &cust); err != nil {
|
||||
tx.Rollback()
|
||||
return err
|
||||
}
|
||||
|
||||
if err := tx.Table("customerlocations").Create(&custloc).Error; err != nil {
|
||||
tx.Rollback()
|
||||
return err
|
||||
}
|
||||
|
||||
tcust.Customerid = cust.Customerid
|
||||
tcust.Tenantid = data.Tenantid
|
||||
tcust.Locationid = data.Locationid
|
||||
tcust.Moduleid = data.Moduleid
|
||||
|
||||
if err := tx.Table("tenantcustomers").Create(&tcust).Error; err != nil {
|
||||
if err := tx.Where("locationid=? AND tenantid=?", locationid, tenantid).Delete(&models.Tenantlocations{}).Error; err != nil {
|
||||
tx.Rollback()
|
||||
return err
|
||||
}
|
||||
@@ -347,6 +306,13 @@ func (r *tenantRepository) CreateLocation(data models.Tenantlocations) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (r *tenantRepository) CreateLocation(data models.Tenantlocations) error {
|
||||
if err := r.db.Create(&data).Error; err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (r *tenantRepository) GetStaffs(tid int) ([]models.StaffInfo, error) {
|
||||
var data []models.StaffInfo
|
||||
|
||||
|
||||
Reference in New Issue
Block a user