Ejemplo n.º 1
0
        public void Sync()
        {
            MedicalContext clientRepo = new MedicalContext();
            Medical2Context serverRepo = new Medical2Context();

            List<Medicine> clientsMedicines = clientRepo.Medicines.OrderBy(x=>x.Id).ToList();
            List<Medicine> serverMedicines = serverRepo.Medicines.OrderBy(x => x.Id).ToList();

            foreach (Medicine org in  clientsMedicines)
            {
                bool isExist = false;
                foreach (Medicine target in serverMedicines)
                {
                    if (org.Id != target.Id) continue;
                    isExist = true;
                    update(org, target);
                    Console.WriteLine("Update: " + org.Id);
                }

                if (isExist) continue;
                clientRepo.Medicines.Remove(org);
                Console.WriteLine("Delete: " + org.Id);
            }

            foreach (Medicine target in serverMedicines)
            {
                bool isExist = false;
                foreach (Medicine org in clientsMedicines)
                {
                    if (org.Id != target.Id) continue;
                    isExist = true;
                }

                if (isExist) continue;
                Medicine news = clone(target);
                clientRepo.Medicines.Add(news);
                Console.WriteLine("Add: " + target.Id);
            }

            clientRepo.SaveChanges();
        }
Ejemplo n.º 2
0
        protected readonly MedicalContext Context;  //= new MedicalContext();
        //protected readonly FigureContext FigureContext = new FigureContext();

        public RepositoryBase(Boolean serverContext)
        {
            this.Context = serverContext ? new Medical2Context() : new MedicalContext();
        }
Ejemplo n.º 3
0
        protected readonly MedicalContext Context; //= new MedicalContext();

        #endregion Fields

        #region Constructors

        //protected readonly FigureContext FigureContext = new FigureContext();
        public RepositoryBase(Boolean serverContext)
        {
            this.Context = serverContext ? new Medical2Context() : new MedicalContext();
        }