// DELETE api/drivers/5 public IHttpActionResult DeleteUser([FromUri] string senderID, [FromUri] string userToDelete) { bool result = false; if (!LoggedUsers.Contains(senderID)) { return(Content(HttpStatusCode.Unauthorized, "Not logged in.")); } else if (!DbAdmin.Exists(senderID)) { return(Content(HttpStatusCode.Unauthorized, "Not a dispatcher.")); } try { if (DbAdmin.Exists(userToDelete)) { //TODO: sta ako obrise samog sebe logout? result = DbAdmin.Delete(userToDelete); } else if (DbDriver.Exists(userToDelete)) { result = DbDriver.Delete(userToDelete); } else if (DbCustomer.Exists(userToDelete)) { result = DbCustomer.Delete(userToDelete); } } catch (Exception e) { Trace.Write($"Error on 'DeleteUser()'. Error message: {e.Message}"); Trace.Write($"[STACK_TRACE] {e.StackTrace}"); return(InternalServerError(e)); } if (result) { return(Ok()); } else { return(NotFound()); } }