예제 #1
0
		private void attach_Devices(Device entity)
		{
			this.SendPropertyChanging();
			entity.City = this;
		}
예제 #2
0
		private void detach_Devices(Device entity)
		{
			this.SendPropertyChanging();
			entity.City = null;
		}
예제 #3
0
        public ActionResult RegisterDevice(string platform, string token,long cityId = 1)
        {
            var rep = Locator.GetService<IDeviceRepository>();
            var device = rep.Find(d => d.Token == token);
            if (device == null)
            {
                device = new Device()
                {
                    DateRegistred = DateTime.Now,
                    Platform = (short) PlatformUtils.Parse(platform),
                    Token = token,
                    CityId = cityId
                };
                rep.Add(device);
                rep.SubmitChanges();
            }
            else
            {
                if (device.CityId != cityId)
                {
                    device.City.Devices.Remove(device);
                    Locator.GetService<ICitiesRepository>().Load(cityId).Devices.Add(device);
                    rep.SubmitChanges();
                }
            }

            return Json(new {content = "OK"});
        }