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