예제 #1
0
        public ActionResult UsersUpdate(CounterModel counter)
        {
            if (ModelState.IsValid)
            {
                using (var db = new GazCountersDbContext())
                {
                    var arepo = new AddressesRepository(db);
                    var address = arepo.GetByID(counter.AddressID);

                    if (address == null)
                        throw new Exception("Address ID cant be found in DB, maybe deleted or data is invalid");

                    counter.AddressData.ToDbAddress(address);
                    arepo.Update(address);

                    arepo.Commit();
                }
            }

            return null;
        }
예제 #2
0
        private IEnumerable<CounterModel> GetCounters()
        {
            using (var db = new GazCountersDbContext())
            {
                var crepo = new CountersRepository(db);
                var counters = crepo.GetAll("Address").ToList();
                var model = counters.Select(s => new CounterModel(s));

                return model;
            }
        }