Esempio n. 1
0
        public ActionResult UpdateLocations(SetRequest rq)
        {
            if (rq == null)
            {
                throw new ArgumentNullException("rq");
            }
            if (!rq.ParentId.HasValue)
            {
                throw new ArgumentException("Request should have parentId");
            }
            long pid = rq.ParentId.Value;

            if (pid <= 0)
            {
                throw new ArgumentException("parentId should be positive");
            }
            if (rq.Edits != null)
            {
                foreach (var e in rq.ToPoco <LocationBaseDeviceMapping>())
                {
                    var data = new DeviceLocationMap {
                        DeviceId = pid, LocationBaseId = e.LocationBaseId, Mapping = e.Mapping
                    };
                    GeneralPersistense.Upsert(data);
                }
            }
            return(ListLocations(pid));
        }
Esempio n. 2
0
 public override void Set()
 {
     //Removing LocationBase mix-in fields
     if (!string.IsNullOrWhiteSpace(this.Mapping))
     {
         var model = new DeviceLocationMap {
             DeviceId = this.DeviceId, LocationBaseId = this.LocationBaseId, Mapping = this.Mapping
         };
         model.Set();
     }
     else
     {
         DeviceLocationMap.Delete(DeviceId, LocationBaseId);
     }
 }