Ejemplo n.º 1
0
		private void attach_Devices(Device entity)
		{
			this.SendPropertyChanging();
			entity.City = this;
		}
Ejemplo n.º 2
0
		private void detach_Devices(Device entity)
		{
			this.SendPropertyChanging();
			entity.City = null;
		}
Ejemplo n.º 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"});
        }