private Dictionary <string, object> prepareDeviceTypeParameters(clsDeviceType prDeviceType) { Dictionary <string, object> par = new Dictionary <string, object>(3); par.Add("Name", prDeviceType.Name); par.Add("Description", prDeviceType.Description); return(par); }
//----------------------------------------------- task 3 part 6----------------------------------- //-----------------------------------------PUT & POST DEVICE TYPES-------------------------------- public string PutDeviceType(clsDeviceType prDeviceType) { // update try { int lcRecCount = clsDbConnection.Execute( "UPDATE DeviceTypes SET Description = @Description WHERE Name = @Name", prepareDeviceTypeParameters(prDeviceType)); if (lcRecCount == 1) { return("One Device Type updated"); } else { return("Unexpected Device Type update count: " + lcRecCount); } } catch (Exception ex) { return(ex.GetBaseException().Message); } }
public string PostDeviceType(clsDeviceType prDeviceType) { // update try { int lcRecCount = clsDbConnection.Execute( "INSERT INTO DeviceTypes(Name, Description) VALUES (@Name, @Description)", prepareDeviceTypeParameters(prDeviceType)); if (lcRecCount == 1) { return("One Device Type added"); } else { return("Unexpected Device Type add count: " + lcRecCount); } } catch (Exception ex) { return(ex.GetBaseException().Message); } }