add model
This commit is contained in:
parent
630a3175ce
commit
87c447e935
@ -99,5 +99,24 @@ namespace PSTW_CentralSystem.Controllers.API
|
|||||||
return Json(qcList);
|
return Json(qcList);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[HttpPost("addData")]
|
||||||
|
public async Task<IActionResult> addData([FromBody] ModuleSettingModel modelSettingList)
|
||||||
|
{
|
||||||
|
var existingModule = await _authDbContext.ModuleSettings.Where(x => x.ModuleName.ToLower() == modelSettingList.ModuleName.ToLower()).FirstOrDefaultAsync();
|
||||||
|
|
||||||
|
if (existingModule != null)
|
||||||
|
{
|
||||||
|
return BadRequest("Module name already exists."); // Return a 400 Bad Request
|
||||||
|
}
|
||||||
|
|
||||||
|
// Add new module
|
||||||
|
modelSettingList.ModuleStatus = 1; // Default status
|
||||||
|
|
||||||
|
_authDbContext.ModuleSettings.Add(modelSettingList);
|
||||||
|
await _authDbContext.SaveChangesAsync();
|
||||||
|
|
||||||
|
|
||||||
|
return Json(modelSettingList);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -42,6 +42,12 @@ namespace PSTW_CentralSystem.Controllers
|
|||||||
|
|
||||||
return View(moduleSettings);
|
return View(moduleSettings);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public IActionResult AddModule()
|
||||||
|
{
|
||||||
|
return View();
|
||||||
|
}
|
||||||
|
|
||||||
public IActionResult ModuleCreate()
|
public IActionResult ModuleCreate()
|
||||||
{
|
{
|
||||||
return View();
|
return View();
|
||||||
|
|||||||
@ -3,7 +3,7 @@ Microsoft Visual Studio Solution File, Format Version 12.00
|
|||||||
# Visual Studio Version 17
|
# Visual Studio Version 17
|
||||||
VisualStudioVersion = 17.11.35327.3
|
VisualStudioVersion = 17.11.35327.3
|
||||||
MinimumVisualStudioVersion = 10.0.40219.1
|
MinimumVisualStudioVersion = 10.0.40219.1
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PSTW_CentralSystem", "PSTW_CentralSystem.csproj", "{1B3D8BB0-F297-4F4B-8C09-6D97CE5D44F1}"
|
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PSTW_CentralSystem", "PSTW_CentralSystem.csproj", "{1B3D8BB0-F297-4F4B-8C09-6D97CE5D44F1}"
|
||||||
EndProject
|
EndProject
|
||||||
Global
|
Global
|
||||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
|
|||||||
93
Views/Admin/AddModule.cshtml
Normal file
93
Views/Admin/AddModule.cshtml
Normal file
@ -0,0 +1,93 @@
|
|||||||
|
|
||||||
|
@{
|
||||||
|
ViewData["Title"] = "Add Module";
|
||||||
|
Layout = "~/Views/Shared/_Layout.cshtml";
|
||||||
|
}
|
||||||
|
|
||||||
|
<div class="row" id="app">
|
||||||
|
<div class="col-md-12 col-lg-12">
|
||||||
|
<div class="card">
|
||||||
|
<div class="card-body">
|
||||||
|
<div class="col-md-12 col-lg-12">
|
||||||
|
<form v-on:submit.prevent="">
|
||||||
|
<div class="card">
|
||||||
|
<div class="card-body">
|
||||||
|
<h5 class="card-title">Settings</h5>
|
||||||
|
<div class="form-group row">
|
||||||
|
<label class="col-md-3 mt-3">Module Name</label>
|
||||||
|
<div class="col-md-6">
|
||||||
|
<input type="text" class="form-control" name="ModuleName" v-model="moduleData.ModuleName" />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="form-group row">
|
||||||
|
<label class="col-md-3 mt-3">Module Access</label>
|
||||||
|
<div class="col-md-6">
|
||||||
|
<select class="form-select shadow-none mt-3" name="AllowedUserType" v-model="moduleData.AllowedUserType" style="height: 36px; width: 100%">
|
||||||
|
<optgroup label="General">
|
||||||
|
<option value="Public">Public</option>
|
||||||
|
<option value="Registered User">Registered User</option>
|
||||||
|
</optgroup>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="border-top">
|
||||||
|
<div class="card-body">
|
||||||
|
<button type="button" class="btn btn-primary" v-on:click="saveData">
|
||||||
|
Add
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
@section Scripts {
|
||||||
|
@{
|
||||||
|
await Html.RenderPartialAsync("_ValidationScriptsPartial");
|
||||||
|
}
|
||||||
|
<script>
|
||||||
|
</script>
|
||||||
|
<script>
|
||||||
|
const app = Vue.createApp({
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
moduleData:{
|
||||||
|
ModuleName : null,
|
||||||
|
AllowedUserType : null,
|
||||||
|
MethodAllowedUserType : "[]",
|
||||||
|
ModuleStatus : "1",
|
||||||
|
Description : null,
|
||||||
|
}
|
||||||
|
};
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
saveData() {
|
||||||
|
fetch('/ModuleAPI/addData', {
|
||||||
|
method: 'POST',
|
||||||
|
headers: {
|
||||||
|
'Content-Type': 'application/json'
|
||||||
|
},
|
||||||
|
body: JSON.stringify(this.moduleData)
|
||||||
|
})
|
||||||
|
.then(response => {
|
||||||
|
if (!response.ok) {
|
||||||
|
throw new Error('Name module already exist');
|
||||||
|
}
|
||||||
|
alert('Module information saved successfully');
|
||||||
|
})
|
||||||
|
.catch(error => {
|
||||||
|
console.error('There was a problem with the update operation:', error);
|
||||||
|
alert('Failed to save data: ' + error.message);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
$(function () {
|
||||||
|
app.mount('#app');
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
}
|
||||||
@ -2,8 +2,9 @@
|
|||||||
"ConnectionStrings": {
|
"ConnectionStrings": {
|
||||||
//"DefaultConnection": "Server=localhost;uid=root;Password='';Database=web_interface;"
|
//"DefaultConnection": "Server=localhost;uid=root;Password='';Database=web_interface;"
|
||||||
//"DefaultConnection": "server=175.136.244.102;user id=root;password=tw_mysql_root;port=3306;database=web_interface"
|
//"DefaultConnection": "server=175.136.244.102;user id=root;password=tw_mysql_root;port=3306;database=web_interface"
|
||||||
"DefaultConnection": "Server=219.92.7.60;Port=3307;uid=installer;password='pstw_mysql_installer';database=pstw_cs;" //DB_dev connection
|
//"DefaultConnection": "Server=219.92.7.60;Port=3307;uid=installer;password='pstw_mysql_installer';database=pstw_cs;", //DB_dev connection
|
||||||
//"DefaultConnection": "Server=219.92.7.60;Port=3307;uid=intern;password='intern_mysql_acct';database=web_interface;"//DB_dev connection
|
//"DefaultConnection": "Server=219.92.7.60;Port=3307;uid=intern;password='intern_mysql_acct';database=web_interface;"//DB_dev connection
|
||||||
|
"DefaultConnection": "Server=127.0.0.1;Port=3306;user=root;password=;database=pstw_cs;" //DB_dev connection - Arif Hilmi
|
||||||
},
|
},
|
||||||
"Logging": {
|
"Logging": {
|
||||||
"LogLevel": {
|
"LogLevel": {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user