public IActionResult Get(int id) { Disp user = Disps.FirstOrDefault(x => x.Id == id); if (user == null) { return(NotFound()); } return(Ok(user)); }
public IActionResult Post(Disp disp) { if (string.IsNullOrWhiteSpace(disp.Name)) { return(BadRequest()); } var s = Process.Start(disp.Name); var res = new Disp { Id = s.Id, Name = $"{s.ProcessName}({s.MainWindowTitle})", Memory = Perm.GetMemory(s.ProcessName) }; return(Ok(res)); }
public IActionResult Delete(int id) { var disp = (from pr in Process.GetProcesses(".") where pr.Id == id select pr).FirstOrDefault(); if (disp == null) { return(BadRequest()); } disp.Kill(); var d = new Disp { Id = disp.Id, Name = $"{disp.ProcessName}({disp.MainWindowTitle})", Memory = "" }; return(Ok(d)); }