/// <summary> /// Find Endpoint Type by EndPoint Type ID /// </summary> /// <param name="id">EndPoint Type ID</param> /// <returns>Endpoint object</returns> public ThingCategory Find(long id) { ThingCategory epType = new ThingCategory(); List<ThingCategory> epTypes = db.ThingCategorys.Where(c => c.ID == id).OrderBy(c => c.Title).ToList(); if (epTypes.Count == 1) { epType = epTypes[0]; } else { throw new Exception("Not Found"); } return epType; }
public ResultInfo.Result Add(string Title,long IconID) { try { ThingCategory cat = new ThingCategory(); cat.Title = Title; cat.IconID = IconID; db.ThingCategorys.Add(cat); db.SaveChanges(); return ResultInfo.GenerateOKResult("Saved", cat.ID); } catch { return ResultInfo.GetResultByID(1); } }