in Webapp/SDAF/Controllers/LandscapeController.cs [411:458]
public async Task<IActionResult> SubmitNewAsync(LandscapeModel landscape)
{
if (ModelState.IsValid)
{
try
{
if (landscape.IsDefault)
{
await UnsetDefault(landscape.Id);
}
landscape.Id = Helper.GenerateId(landscape);
DateTime currentDateAndTime = DateTime.Now;
landscape.LastModified = currentDateAndTime.ToShortDateString();
await _landscapeService.CreateAsync(new LandscapeEntity(landscape));
TempData["success"] = "Successfully created workload zone " + landscape.Id;
string id = landscape.Id;
string path = $"/LANDSCAPE/{id}/{id}.tfvars";
string content = Helper.ConvertToTerraform(landscape);
byte[] bytes = Encoding.UTF8.GetBytes(content);
AppFile file = new()
{
Id = WebUtility.HtmlEncode(id),
Content = bytes,
UntrustedName = id,
Size = bytes.Length,
UploadDT = DateTime.UtcNow
};
await _landscapeService.CreateTFVarsAsync(file);
return RedirectToAction("Index");
}
catch (Exception e)
{
ModelState.AddModelError("LandscapeId", "Error creating workload zone: " + e.Message);
}
}
landscapeView.SapObject = landscape;
ViewBag.ValidImageOptions = (imagesOffered.Length != 0);
ViewBag.ImageOptions = imageOptions;
return View("Edit", landscapeView);
}