1+ import { Role , Material_Type , User , Assembly , Material_Status , Material } from '@prisma/client' ;
12import {
23 isAdmin ,
34 isGuest ,
@@ -6,11 +7,12 @@ import {
67 isProject ,
78 LinkCreateArgs ,
89 LinkType ,
10+ Manufacturer ,
11+ MaterialType ,
912 Project ,
1013 WbsNumber ,
1114 wbsPipe
1215} from 'shared' ;
13- import { Manufacturer , Role , Material_Type , User , Assembly , Material_Status , Material } from '@prisma/client' ;
1416import projectQueryArgs from '../prisma-query-args/projects.query-args' ;
1517import prisma from '../prisma/prisma' ;
1618import projectTransformer from '../transformers/projects.transformer' ;
@@ -40,10 +42,12 @@ import {
4042import linkQueryArgs from '../prisma-query-args/links.query-args' ;
4143import linkTypeQueryArgs from '../prisma-query-args/link-types.query-args' ;
4244import manufacturerQueryArgs from '../prisma-query-args/manufacturers.query-args' ;
45+ import materialTypeQueryArgs from '../prisma-query-args/material-type.query-args' ;
4346import { linkTypeTransformer } from '../transformers/links.transformer' ;
4447import { updateLinks , linkToChangeListValue } from '../utils/links.utils' ;
4548import { manufacturerTransformer } from '../transformers/manufacturer.transformer' ;
4649import { isUserPartOfTeams } from '../utils/teams.utils' ;
50+ import { materialTypeTransformer } from '../transformers/material-type.transformer' ;
4751
4852export default class ProjectsService {
4953 /**
@@ -773,7 +777,7 @@ export default class ProjectsService {
773777 return assembly ;
774778 }
775779
776- /*
780+ /**
777781 * Creates a new Manufacturer
778782 * @param submitter the user who's creating the manufacturer
779783 * @param name the name of the manufacturer
@@ -836,6 +840,7 @@ export default class ProjectsService {
836840 }
837841 /**
838842 * Get all the manufacturers in the database.
843+ * @param submitter the user who's getting all manufacturers
839844 * @returns all the manufacturers
840845 */
841846 static async getAllManufacturers ( submitter : User ) : Promise < Manufacturer [ ] > {
@@ -850,6 +855,23 @@ export default class ProjectsService {
850855 ) . map ( manufacturerTransformer ) ;
851856 }
852857
858+ /**
859+ * Get all the material types in the database.
860+ * @param submitter the user who's getting all material types
861+ * @returns all the material types
862+ */
863+ static async getAllMaterialTypes ( submitter : User ) : Promise < MaterialType [ ] > {
864+ if ( submitter . role === Role . GUEST ) {
865+ throw new AccessDeniedGuestException ( 'Get Material Types' ) ;
866+ }
867+
868+ return (
869+ await prisma . material_Type . findMany ( {
870+ ...materialTypeQueryArgs
871+ } )
872+ ) . map ( materialTypeTransformer ) ;
873+ }
874+
853875 /**
854876 * Create a new material type
855877 * @param name the name of the new material type
0 commit comments