public string Decode(string input) { string msg; string opNumber = input.Remove(3); DBEdit dbEdit = new DBEdit(); switch (opNumber) { case "#01": //Max population asked msg = dbEdit.MaxPop(); break; case "#02": //Add city to DB msg = dbEdit.AddCity(DecodeCity(input)) ? "Success" : "Failed"; break; case "#99": //Testing connection msg = "Success"; break; default: msg = "Unknown operation"; break; } return msg; }
public string Decode(string input) { string msg; string opNumber = ""; if (input.Length > 3) { opNumber = input.Remove(3); } DBEdit dbEdit = new DBEdit(); switch (opNumber) { case "#01": //Max population asked msg = dbEdit.MaxPop(); break; case "#02": //Add city to DB msg = dbEdit.AddCity(DecodeCity(input)) ? Resources.Success : Resources.Failed; break; case "#03": //Delete city from DB msg = dbEdit.RemoveCity(DecodeID(input)) ? Resources.Success : Resources.Failed; break; case "#04": //Edit city by id in DB msg = dbEdit.EditCity(DecodeCity(input).Id, DecodeCity(input)) ? Resources.Success : Resources.Failed; break; case "#12": //Add person to DB msg = dbEdit.AddPerson(DecodePerson(input)) ? Resources.Success : Resources.Failed; break; case "#13": //Edit person by id DB msg = dbEdit.EditPerson(DecodePerson(input).Id, DecodePerson(input)) ? Resources.Success : Resources.Failed; break; case "#14": //Delete person from DB msg = dbEdit.RemovePerson(DecodeID(input)) ? Resources.Success : Resources.Failed; break; case "#20": //Send report data msg = dbEdit.Report(); break; case "#99": //Testing connection msg = Resources.Success; break; default: msg = "Unknown operation"; break; } return msg; }
public string MaxPopulation() { DBEdit dbedit = new DBEdit(); return dbedit.MaxPop(); }