//Get the Server to Delete public ServerDeleteVM GetDeleteServer(string referenceID) { try { ServerDeleteVM server = _context.Server.Where(a => a.ReferenceID == referenceID) .Select(b => new ServerDeleteVM { ServerName = b.ServerName, ReferenceID = b.ReferenceID, Description = b.Description, StatusName = b.Status.StatusName, Location = b.DataCenterLocation.Location, ServerTypeName = b.ServerType.ServerTypeName }).FirstOrDefault(); return(server); } catch (Exception e) { if (e is SqlException) { } return(null); } }
public ActionResult Delete(ServerDeleteVM server) { if (ModelState.IsValid) { if (_serverRepo.DeleteServer(server.ReferenceID, out string msg)) { TempData["SuccessMsg"] = msg; return(RedirectToAction("Index")); } TempData["ErrorMsg"] = msg; } return(View(server)); }