Example #1
0
 /// <summary>
 /// Find Thing by Thing ID
 /// </summary>
 /// <param name="id">Thing ID</param>
 /// <returns>Thing object</returns>
 public Thing Find(long id)
 {
     Thing dev = new Thing();
     List<Thing> devs = db.Things.Where(l => l.ID == id).ToList();
     if (devs.Count == 1)
     {
         dev = devs[0];
     }
     else
     {
         throw new Exception("Not Found");
     }
     return dev;
 }
Example #2
0
 public ResultInfo.Result Add(string title, long categoryID, int utc_Diff,string userID)
 {
     Thing thing = new Thing();
     try
     {
         thing.CategoryID = categoryID;
         thing.Title = title;
         thing.UTC_Diff = utc_Diff;
         thing.CreateByUser = userID;
         thing.CreateTimeStamp = DateTime.UtcNow.AddHours(Config.App_TimeZone);
         db.Things.Add(thing);
         db.SaveChanges();
     }
     catch (Exception ex)
     {
         return ResultInfo.GenerateErrorResult(ex.InnerException.ToString());
     }
     return ResultInfo.GenerateOKResult("Saved", thing.ID);
 }