@tomei/rental
Version:
Tomei Rental Package
121 lines • 5.38 kB
JavaScript
"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.HirerChangeRequestNewHirer = void 0;
const general_1 = require("@tomei/general");
const hirer_change_request_new_hirer_repository_1 = require("./hirer-change-request-new-hirer.repository");
const activity_history_1 = require("@tomei/activity-history");
class HirerChangeRequestNewHirer extends general_1.ObjectBase {
get NewHirerId() {
return this.ObjectId;
}
set NewHirerId(value) {
this.ObjectId = value;
}
constructor(attr) {
super();
this.ObjectType = 'HirerChangeRequestNewHirer';
this.TableName = 'hirerChangeRequest_NewHirer';
if (attr) {
this.NewHirerId = attr.NewHirerId;
this.RequestId = attr.RequestId;
this.FullName = attr.FullName;
this.Email = attr.Email;
this.IdType = attr.IdType;
this.IdNo = attr.IdNo;
this.ContactNo = attr.ContactNo;
this.Relationship = attr.Relationship;
this.Address = attr.Address;
this.City = attr.City;
this.State = attr.State;
this.Postcode = attr.Postcode;
this.Country = attr.Country;
}
}
static init(newHirerId, dbTransaction) {
return __awaiter(this, void 0, void 0, function* () {
try {
if (newHirerId) {
const hirerChangeReqNewHirer = yield HirerChangeRequestNewHirer._Repository.findByPk(newHirerId, dbTransaction);
if (hirerChangeReqNewHirer) {
return new HirerChangeRequestNewHirer(hirerChangeReqNewHirer.get({ plain: true }));
}
else {
throw new general_1.ClassError('HirerChangeRequestNewHirer', 'HirerChangeRequestNewHirerErrMsg00', 'HirerChangeRequestNewHirer not found');
}
}
return new HirerChangeRequestNewHirer();
}
catch (error) {
throw error;
}
});
}
static findAll(search, dbTransaction) {
return __awaiter(this, void 0, void 0, function* () {
try {
const results = yield HirerChangeRequestNewHirer._Repository.findAll({
where: Object.assign({}, search),
transaction: dbTransaction,
});
return results.map((result) => new HirerChangeRequestNewHirer(result.get({ plain: true })));
}
catch (error) {
console.error('Error finding all HirerChangeRequestNewHirer:', error);
throw error;
}
});
}
toJSON() {
return {
NewHirerId: this.NewHirerId,
RequestId: this.RequestId,
FullName: this.FullName,
Email: this.Email,
IdType: this.IdType,
IdNo: this.IdNo,
ContactNo: this.ContactNo,
Relationship: this.Relationship,
Address: this.Address,
City: this.City,
State: this.State,
Postcode: this.Postcode,
Country: this.Country,
};
}
create(loginUser, dbTransaction) {
return __awaiter(this, void 0, void 0, function* () {
try {
this.ObjectId = this.createId();
const entityValueAfter = this.toJSON();
const newHirer = yield HirerChangeRequestNewHirer._Repository.create(entityValueAfter, {
transaction: dbTransaction,
});
const activity = new activity_history_1.Activity();
activity.ObjectId = this._createId();
activity.Action = activity_history_1.ActionEnum.CREATE;
activity.Description = `Created new Hirer Change Request New Hirer`;
activity.EntityId = newHirer.NewHirerId;
activity.EntityType = this.ObjectType;
activity.EntityValueBefore = JSON.stringify({});
activity.EntityValueAfter = JSON.stringify(newHirer);
yield activity.create(loginUser.ObjectId, dbTransaction);
}
catch (error) {
console.error('Error creating HirerChangeRequestNewHirer:', error);
throw error;
}
});
}
}
exports.HirerChangeRequestNewHirer = HirerChangeRequestNewHirer;
HirerChangeRequestNewHirer._Repository = new hirer_change_request_new_hirer_repository_1.HirerChangeRequestNewHirerRepository();
//# sourceMappingURL=hirer-change-request-new-hirer.js.map