Esempio n. 1
0
 public ResultInfo.Result DeattachThing(long lnkID, string userID)
 {
     try
     {
         List <LinkThingsLocation> lnks = db.LinkThingsLocations.Where(l => l.ID == lnkID).ToList();
         if (lnks.Count != 1)
         {
             return(ResultInfo.GetResultByID(1));
         }
         LinkThingsLocation lnk = lnks[0];
         db.LinkThingsLocations.Remove(lnk);
         db.SaveChanges();
         return(ResultInfo.GenerateOKResult("Saved"));
     }
     catch
     {
         return(ResultInfo.GetResultByID(1));
     }
 }
Esempio n. 2
0
        public ResultInfo.Result AttachThing(long locationID, long ThingID, string userID)
        {
            try
            {
                Thing thing            = db.Things.Find(ThingID);
                LinkThingsLocation lnk = new LinkThingsLocation();

                lnk.LocationID      = locationID;
                lnk.ThingID         = ThingID;
                lnk.CreateByUser    = userID;
                lnk.CreateTimeStamp = DateTime.UtcNow;
                db.LinkThingsLocations.Add(lnk);

                db.SaveChanges();
                return(ResultInfo.GenerateOKResult("Saved"));
            }
            catch (Exception ex)
            {
                return(ResultInfo.GenerateErrorResult(ex.Message));
            }
        }