public bool Delete(string dn, string samName) { ComputerRepository ldapComputer = new ComputerRepository(_mySQLContext); CredentialRepository credential = new CredentialRepository(_mySQLContext); Computer result = new Computer(); credential.DN = dn; result = ldapComputer.FindBySamName(credential, samName); try { if (result != null) { return(ldapComputer.Delete(credential, result)); } else { return(false); } } catch (Exception e) { Console.WriteLine("\r\nUnexpected exception occurred:\r\n\t" + e.GetType() + ":" + e.Message); return(false); } }
public HttpResponseMessage DeleteComputer(int computerId) { var repository = new ComputerRepository(); var result = repository.Delete(computerId); if (result) { return(Request.CreateResponse(HttpStatusCode.OK)); } return(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, "Could not delete computer, please try again later.")); }