Exemple #1
0
        public void should_Sync_New_Default_Facility()
        {
            var practices = Builder <Practice> .CreateListOfSize(2).All()
                            .With(x => x.Code           = DateTime.Now.Ticks.ToString())
                            .With(x => x.CountyId       = 47)
                            .With(x => x.PracticeTypeId = string.Empty)
                            .With(x => x.IsDefault      = false)
                            .Build().ToList();

            practices[1].IsDefault = true;

            foreach (var practice in practices)
            {
                _practiceRepository.Sync(practice);
                _practiceRepository.Save();
            }


            var facs = _practiceRepository.GetAll().ToList();

            Assert.That(facs.Where(x => x.IsDefault).ToList().Count == 1);

            var facility = facs.FirstOrDefault(x => x.IsDefault);

            Assert.IsNotNull(facility);
            Assert.AreEqual("Facility", facility.PracticeTypeId);
            Assert.AreEqual(practices[1].Code, facility.Code);
            Console.WriteLine(facility);
        }
Exemple #2
0
        public void should_Sync_Multiple_New_Facility()
        {
            var practices = Builder <Practice> .CreateListOfSize(3).All()
                            .With(x => x.Code           = DateTime.Now.Ticks.ToString())
                            .With(x => x.CountyId       = 47)
                            .With(x => x.PracticeTypeId = string.Empty)
                            .With(x => x.IsDefault == false)
                            .Build();

            practices[2].IsDefault = true;
            Console.WriteLine($"{practices[2]} <{practices[2].IsDefault}>");
            _practiceRepository.Sync(practices);

            _practiceRepository = new PracticeRepository(_context);
            foreach (var practice in practices)
            {
                var facility = _practiceRepository.Get(practice.Id);
                Assert.IsNotNull(facility);
                Assert.AreEqual("Facility", facility.PracticeTypeId);
                Console.WriteLine($"{facility} [{facility.IsDefault}]");
            }
            var facilities = _practiceRepository.GetAll().ToList();

            Assert.True(facilities.Where(x => x.IsDefault).ToList().Count == 1);
        }
        public Practice GetLocal()
        {
            var existingPractice =
                _practiceRepository.GetAll(x => x.IsDefault && x.Code != "1").ToList().FirstOrDefault();

            if (null == existingPractice)
            {
                throw new ArgumentException("Facility hAPI.Server not setup");
            }

            return(existingPractice);
        }
Exemple #4
0
        public void SavePractce(Practice practice)
        {
            var practices = _practiceRepository.GetAll().ToList();

            if (practices.Count == 0)
            {
                _practiceRepository.Save(practice);
            }

            foreach (var p in practices)
            {
                p.IsDefault = false;
                _practiceRepository.Update(p);
            }
            practice.IsDefault = true;
            _practiceRepository.InsertOrUpdate(practice);
        }
Exemple #5
0
        public void should_Sync_Multiple_Updated_Default_Facility()
        {
            var practice = TestData.TestPractices().First();

            practice.Code      = "14080";
            practice.Name      = "Maun";
            practice.IsDefault = true;

            _practiceRepository.Sync(new List <Practice> {
                practice
            });

            _practiceRepository = new PracticeRepository(_context);
            var facs = _practiceRepository.GetAll().ToList();

            Assert.That(facs.Where(x => x.IsDefault).ToList().Count == 1);
            var facility = facs.FirstOrDefault(x => x.IsDefault);

            Assert.IsNotNull(facility);
            Assert.AreEqual("Maun", facility.Name);
            Console.WriteLine(facility);
        }
 public IEnumerable <PracticeDto> GetPractices(int pageSize = -1, int pageNo = -1)
 {
     return(repository.GetAll(pageSize, pageNo));
 }
 public List <Practice> GetAll()
 {
     return(_practiceRepository.GetAll().ToList());
 }
Exemple #8
0
 public IEnumerable <Practice> GetDefaultPractices()
 {
     return(_practiceRepository.GetAll(x => x.IsDefault).ToList());
 }