-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Peter Hornburger
committed
Jan 21, 2024
1 parent
ccf4a6f
commit 3d170bc
Showing
7 changed files
with
383 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,160 @@ | ||
import {Document, model} from "mongoose"; | ||
import {DebugClass} from "../debug"; | ||
import {Constclass} from "../constclass"; | ||
import * as mongoose from "mongoose"; | ||
import {ISimontabellestruktur, Simontabelleshema} from "../datenstrukturen/simontabellestruktur_server"; | ||
|
||
export class SimontabelleDBClass { | ||
|
||
private Debug: DebugClass; | ||
private Const: Constclass; | ||
|
||
constructor() { | ||
|
||
this.Debug = new DebugClass(); | ||
this.Const = new Constclass(); | ||
} | ||
|
||
public ReadSimontabelleliste(projektkey: string): Promise<any> { | ||
|
||
try { | ||
|
||
let SimontabellemodelClass: mongoose.Model<mongoose.Document>; | ||
let Liste: ISimontabellestruktur[] = []; | ||
|
||
return new Promise((resolve, reject) => { | ||
|
||
SimontabellemodelClass = model(this.Const.SimontabellencollectionName, Simontabelleshema); | ||
|
||
SimontabellemodelClass.find( { Deleted: false, Projektkey: projektkey } ).then((data: any) => { | ||
|
||
data.forEach((simontabelle) => { | ||
|
||
Liste.push(simontabelle._doc); | ||
}); | ||
|
||
resolve(Liste); | ||
|
||
}).catch((error: any) => { | ||
|
||
reject(error); | ||
}); | ||
|
||
}); | ||
|
||
} catch (error) { | ||
|
||
this.Debug.ShowErrorMessage(error.message, error, 'SimontabelleDBClass', 'ReadSimontabelleliste'); | ||
} | ||
} | ||
|
||
public RemoveSimontabelle(simontabelle: ISimontabellestruktur): Promise<any> { | ||
|
||
try { | ||
|
||
let SimontabellemodelClass: mongoose.Model<mongoose.Document>; | ||
|
||
return new Promise<any>((resolve, reject) => { | ||
|
||
SimontabellemodelClass = model(this.Const.SimontabellencollectionName, Simontabelleshema); | ||
|
||
SimontabellemodelClass.deleteOne({_id: simontabelle._id}).then((result: any) => { | ||
|
||
resolve(true); | ||
|
||
}).catch((error) => { | ||
|
||
reject(error); | ||
}); | ||
|
||
}); | ||
|
||
} catch (error) { | ||
|
||
this.Debug.ShowErrorMessage(error.message, error, 'SimontabelleDBClass', 'RemoveSimontabelle'); | ||
} | ||
} | ||
|
||
public AddSimontabelle(data: ISimontabellestruktur):Promise<any> { | ||
|
||
try { | ||
|
||
let Simontabellemodel: mongoose.Document; | ||
|
||
return new Promise<any>((resolve, reject) => { | ||
|
||
delete data._id; | ||
|
||
Simontabellemodel = this.GetSimontabelleModel(data); | ||
|
||
Simontabellemodel.save().then((result: Document<any>) => { | ||
|
||
resolve(result); | ||
|
||
}).catch((error) => { | ||
|
||
reject(error); | ||
}); | ||
}); | ||
|
||
} catch (error) { | ||
|
||
this.Debug.ShowErrorMessage(error.message, error, 'SimontabelleDBClass', 'AddSimontabelle'); | ||
} | ||
} | ||
|
||
public UpdateSimontabelle(data: ISimontabellestruktur):Promise<any> { | ||
|
||
try { | ||
|
||
let SImontabellemodelClass: mongoose.Model<mongoose.Document>; | ||
|
||
return new Promise<any>((resolve, reject) => { | ||
|
||
SImontabellemodelClass = model(this.Const.SimontabellencollectionName, Simontabelleshema); | ||
|
||
SImontabellemodelClass.findById(data._id).then((simontabelle: mongoose.Document) => { | ||
|
||
if(simontabelle) { | ||
|
||
simontabelle.set(data); | ||
simontabelle.save().then((result: Document) => { | ||
|
||
resolve(result); | ||
|
||
}).catch((error) => { | ||
|
||
reject(error); | ||
}); | ||
} | ||
else { | ||
|
||
resolve(null); | ||
} | ||
}).catch((error) => { | ||
|
||
reject(error); | ||
}); | ||
}); | ||
|
||
} catch (error) { | ||
|
||
this.Debug.ShowErrorMessage(error.message, error, 'SimontabelleDBClass', 'UpdateSimontabelle'); | ||
} | ||
} | ||
|
||
public GetSimontabelleModel(data: ISimontabellestruktur): mongoose.Document { | ||
|
||
try { | ||
|
||
const SimontabellemodelClass = model(this.Const.SimontabellencollectionName, Simontabelleshema); | ||
const Simontabellemodel: mongoose.Document = new SimontabellemodelClass(data); | ||
|
||
return Simontabellemodel; | ||
} | ||
catch (error) { | ||
|
||
this.Debug.ShowErrorMessage(error.message, error, 'SimontabelleDBClass', 'GetSimontabelleModel'); | ||
} | ||
} | ||
} |
22 changes: 22 additions & 0 deletions
22
src/datenstrukturen/simontabellebesondereleistungstruktur_server.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import mongoose from "mongoose"; | ||
|
||
interface ISimontabellebesondereleistungstruktur { | ||
|
||
LeistungID: string; | ||
Nummer: string; | ||
Titel: string; | ||
Beschreibung: string; | ||
Honorar: number; | ||
}; | ||
|
||
const Simontabellebesondereleistungshema = new mongoose.Schema({ | ||
|
||
LeistungID: {type: String, required: false}, | ||
Nummer: {type: String, required: false}, | ||
Titel: {type: String, required: false}, | ||
Beschreibung: {type: String, required: false}, | ||
Honorar: {type: Number, required: false, default: 0}, | ||
|
||
}, {_id: false} ); | ||
|
||
export { ISimontabellebesondereleistungstruktur, Simontabellebesondereleistungshema }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import mongoose from "mongoose"; | ||
|
||
interface ISimontabelleeintragstruktur { | ||
|
||
Buchstabe: string; | ||
Beschreibung: string; | ||
Von: number; | ||
Bis: number; | ||
Vertrag: number; | ||
}; | ||
|
||
const Simontabelleeintragshema = new mongoose.Schema({ | ||
|
||
Buchstabe: {type: String, required: false}, | ||
Vertrag: {type: String, required: false}, | ||
|
||
}, {_id: false}); | ||
|
||
export { ISimontabelleeintragstruktur, Simontabelleeintragshema }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import mongoose from "mongoose"; | ||
import {Bautagebucheintragshema} from "./bautagebucheintragstruktur_server"; | ||
import {IVerfasserstruktur, Verfassershema} from "./verfasserstruktur_server"; | ||
import {ISimontabelleeintragstruktur, Simontabelleeintragshema} from "./simontabelleeintragstruktur_server"; | ||
import { | ||
ISimontabellebesondereleistungstruktur, | ||
Simontabellebesondereleistungshema | ||
} from "./simontabellebesondereleistungstruktur_server"; | ||
|
||
interface ISimontabellestruktur { | ||
|
||
_id: string; | ||
Projektkey: string; | ||
Leistungsphase: string; | ||
Anlagengruppe: number; | ||
Durchschnittswert: number; | ||
Verfasser: IVerfasserstruktur; | ||
Eintraegeliste: ISimontabelleeintragstruktur[]; | ||
Deleted: boolean; | ||
Kosten: number; | ||
Honorar: number; | ||
Umbauzuschlag: number; | ||
Nebenkosten: number; | ||
Besondereleistungenliste: ISimontabellebesondereleistungstruktur[]; | ||
}; | ||
|
||
const Simontabelleshema = new mongoose.Schema({ | ||
|
||
Projektkey: {type: String, required: false}, | ||
Leistungsphase: {type: String, required: false}, | ||
Kosten: {type: Number, required: false, default: 0}, | ||
Honorar: {type: Number, required: false, default: 0}, | ||
Umbauzuschlag: {type: Number, required: false, default: 0}, | ||
Nebenkosten: {type: Number, required: false, default: 0}, | ||
Besondereleistungenliste: [Simontabellebesondereleistungshema], | ||
Anlagengruppe: {type: Number, required: false}, | ||
Deleted: {type: Boolean, required: false, default: true}, | ||
Verfasser: Verfassershema, | ||
Eintraegeliste: [Simontabelleeintragshema], | ||
}); | ||
|
||
export { ISimontabellestruktur, Simontabelleshema }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.