Example #1
0
        public ActionResult Create(Person person, int CityId)
        {
            person.CityId = CityId;
            person.City   = db.Cities.First(x => x.CityId == CityId);

            db.People.Add(person);

            db.SaveChanges();

            return(RedirectToAction("Index"));
        }
Example #2
0
        public ActionResult Edit(Country country, params int[] Cities)
        {
            if (country != null)
            {
                var model = _db.Countries.Include("Cities")
                            .First(x => x.CountryId == country.CountryId);
                model.CountryName = country.CountryName;
                model.Population  = country.Population;

                if (Cities != null)
                {
                    foreach (var item in Cities)
                    {
                        var removeMe = model.Cities.First(x => x.CityId == item);
                        model.Cities.Remove(removeMe);
                        _db.Cities.Remove(removeMe);
                    }
                }
                _db.SaveChanges();
            }

            return(RedirectToAction("Index"));
        }
        public bool DeleteV2([FromUri] string uuid)
        {
            RightsResponseModel rights = UserRights.GetUserSession(Db, Request);

            if (rights.Session != null)
            {
                rights.Session.logout_time = DateTime.UtcNow;
                var deviceForThisUuid =
                    CmsDb.Devices.FirstOrDefault(
                        d => d.DeviceUUID == uuid && d.DeviceOwner.IbaId == rights.Session.record_id);
                if (deviceForThisUuid != null)
                {
                    deviceForThisUuid.PushToken = "";
                    CmsDb.SaveChanges();
                }
                Db.SaveChanges();
            }
            return(true);
        }