/// <summary> /// Find Command by ID /// </summary> /// <param name="id">Command ID</param> /// <returns>Command object</returns> public EndPointCommand Find(long id) { EndPointCommand cmd = new EndPointCommand(); List<EndPointCommand> cmds = db.EndPointCommands.Where(l => l.ID == id).ToList(); if (cmds.Count == 1) { cmd = cmds[0]; } else { throw new Exception("Not Found"); } return cmd; }
public ResultInfo.Result Add(string title, long EndPointID, string description, string commandCode, string ownerID) { try { EndPointCommand cmd = new EndPointCommand(); cmd.Title = title; cmd.EndPointID = EndPointID; cmd.Description = description; cmd.CommandCode = commandCode; cmd.OwnerID = ownerID; db.EndPointCommands.Add(cmd); db.SaveChanges(); return ResultInfo.GenerateOKResult("Saved", cmd.ID); } catch { return ResultInfo.GetResultByID(1); } }