public async Task <bool> SaveCommand(int ID, string Name, string Response, StreamCommandMode Mode, int StreamID, int AutoInterval = 0) { try { var command = _context.StreamCommand.Where(x => x.ID == ID).FirstOrDefault(); if (command != null) { command.name = Name; command.response = Response; command.Mode = Mode; command.streamID = StreamID; if (Mode == StreamCommandMode.Auto) { command.AutoInverval = AutoInterval; } _context.SaveChanges(); return(true); } } catch (Exception ex) { Console.WriteLine(ex.ToString()); } return(false); }
public async Task <bool> CreateCommand(string Name, string Response, StreamCommandMode Mode, int StreamID) { try { var command = new StreamCommand(); command.name = Name; command.response = Response; command.Mode = Mode; command.streamID = StreamID; _context.StreamCommand.Add(command); _context.SaveChanges(); return(true); } catch (Exception ex) { Console.WriteLine(ex.ToString()); } return(false); }