Testing failer uncomment issue sorted API-Docker updated based on the Failed testcase
This commit is contained in:
@@ -1,33 +1,55 @@
|
||||
import { Request, Response } from "express";
|
||||
import environmentModel from "../../../shared/model/environments/environments-Model.ts";
|
||||
|
||||
export const setEnvironment = async (data: any) => {
|
||||
const {
|
||||
userId,
|
||||
roofVisibility,
|
||||
wallVisibility,
|
||||
shadowVisibility,
|
||||
organization,
|
||||
} = data;
|
||||
try {
|
||||
const findvalue = await environmentModel(organization).findOne({
|
||||
userId: userId,
|
||||
});
|
||||
if (findvalue) {
|
||||
const updatevalue = await environmentModel(organization).findOneAndUpdate(
|
||||
{ userId: userId },
|
||||
{
|
||||
roofVisibility: roofVisibility,
|
||||
wallVisibility: wallVisibility,
|
||||
shadowVisibility: shadowVisibility,
|
||||
},
|
||||
{ new: true }
|
||||
);
|
||||
return {
|
||||
success: true,
|
||||
message: "evironments updated",
|
||||
data: updatevalue,
|
||||
organization: organization,
|
||||
};
|
||||
} else {
|
||||
const newValue = await environmentModel(organization).create({
|
||||
userId,
|
||||
roofVisibility,
|
||||
wallVisibility,
|
||||
shadowVisibility,
|
||||
});
|
||||
|
||||
|
||||
export const setEnvironment = async (data: any,) => {
|
||||
const { userId,roofVisibility,wallVisibility,shadowVisibility, organization } = data
|
||||
try {
|
||||
|
||||
const findvalue = await environmentModel(organization).findOne({ userId: userId })
|
||||
if (findvalue) {
|
||||
const updatevalue = await environmentModel(organization).findOneAndUpdate(
|
||||
{ userId: userId }, { roofVisibility:roofVisibility,wallVisibility:wallVisibility,shadowVisibility:shadowVisibility }, { new: true });
|
||||
// res.status(201).json(updatevalue);
|
||||
return { success: true, message: 'evironments updated', data: updatevalue,organization:organization }
|
||||
|
||||
} else {
|
||||
const newValue = await environmentModel(organization).create({ userId, roofVisibility, wallVisibility,shadowVisibility });
|
||||
|
||||
return { success: true, message: 'evironments created', data: newValue,organization:organization }
|
||||
// res.status(201).json(newValue);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Send response with the created document
|
||||
} catch (error) {
|
||||
console.error('Error creating evironments:', error);
|
||||
return { success: false, message: 'Error creating or updating evironments', error ,organization:organization}
|
||||
return {
|
||||
success: true,
|
||||
message: "evironments created",
|
||||
data: newValue,
|
||||
organization: organization,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
} catch (error) {
|
||||
console.error("Error creating evironments:", error);
|
||||
return {
|
||||
success: false,
|
||||
message: "Error creating or updating evironments",
|
||||
error,
|
||||
organization: organization,
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user