public ActionResult UpdateOrCreateStore(MyStore model)
 {
     try
     {
         Onboard2DbContext db = new Onboard2DbContext();
         if (model.Id > 0)
         {
             //update
             Store stor = db.Stores.FirstOrDefault(x => x.Id == model.Id);
             if (stor != null)
             {
                 stor.Id      = model.Id;
                 stor.Name    = model.Name;
                 stor.Address = model.Address;
             }
             db.SaveChanges();
         }
         else
         {
             //Insert
             Store stor = new Store();
             stor.Name    = model.Name;
             stor.Address = model.Address;
             db.Stores.Add(stor);
             db.SaveChanges();
         }
         return(RedirectToAction("GetStoreList"));
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Пример #2
0
        public bool DestroySignedCertificates()
        {
            var myCertificates   = new X509Certificate2Collection();
            var rootCertificates = new X509Certificate2Collection();

            try
            {
                lock (MyStore)
                {
                    MyStore.Open(OpenFlags.ReadWrite);

                    var myStoreCertificates = MyStore.Certificates
                                              .Find(X509FindType.FindByIssuerName, Issuer, false);

                    myCertificates.AddRange(myStoreCertificates);
                }
                lock (RootStore)
                {
                    RootStore.Open(OpenFlags.ReadWrite);

                    var myRootCertificates = RootStore.Certificates
                                             .Find(X509FindType.FindByIssuerName, Issuer, false);

                    rootCertificates.AddRange(myRootCertificates);
                }
                return(DestroySignedCertificates(myCertificates, rootCertificates));
            }
            finally
            {
                MyStore.Close();
                RootStore.Close();
            }
        }
Пример #3
0
 protected virtual void Dispose(bool disposing)
 {
     if (disposing)
     {
         MyStore.Close();
         RootStore.Close();
     }
 }
        public static MyStoreVM SetSubData(MyStore data, Guid aid)
        {
            var model = MyStoreVM.MToVM(data);

            model.StoreCategory        = StatusTypesReferencesVM.MToVM(StatusTypesReferencesService.GetByID(data.StoreCategoryID));
            model.StoreLogo            = ImageLinkStorageVM.MToVM(ImageLinkStorageService.GetByID(data.StoreLogoID, data.ID, aid));
            model.StoreBackgroundImage = ImageLinkStorageVM.MToVM(ImageLinkStorageService.GetByID(data.StoreBackgroundImageID, data.ID, aid));
            return(model);
        }
Пример #5
0
        public void Dispose()
        {
            if (MyStore != null)
            {
                MyStore.Close();
            }

            if (RootStore != null)
            {
                RootStore.Close();
            }
        }
        // ADD OR EDIT
        public ActionResult AddOrEdit(int Id)
        {
            Onboard2DbContext db    = new Onboard2DbContext();
            MyStore           model = new MyStore();

            if (Id > 0)
            {
                Store stor = db.Stores.SingleOrDefault(x => x.Id == Id);
                model.Id      = stor.Id;
                model.Name    = stor.Name;
                model.Address = stor.Address;
            }
            return(PartialView("AddOrEdit", model));
        }
Пример #7
0
        public void TestImmediateStore()
        {
            var env = new Environment();
            var res = new MyStore(env);

            Assert.AreEqual(0, res.Count);
            Assert.AreEqual(0, res.PutQueueLength);
            Assert.AreEqual(0, res.GetQueueLength);

            var put = res.Put(1);

            Assert.IsTrue(put.IsTriggered);
            Assert.AreEqual(1, res.Count);
            Assert.AreEqual(0, res.PutQueueLength);
            Assert.AreEqual(0, res.GetQueueLength);

            var get = res.Get();

            Assert.IsTrue(get.IsTriggered);
            Assert.AreEqual(0, res.Count);
            Assert.AreEqual(0, res.PutQueueLength);
            Assert.AreEqual(0, res.GetQueueLength);

            get = res.Get();
            Assert.IsFalse(get.IsTriggered);
            Assert.AreEqual(0, res.Count);
            Assert.AreEqual(0, res.PutQueueLength);
            Assert.AreEqual(1, res.GetQueueLength);

            put = res.Put(1);
            Assert.IsTrue(put.IsTriggered);
            Assert.AreEqual(1, res.Count);
            Assert.AreEqual(0, res.PutQueueLength);
            Assert.AreEqual(1, res.GetQueueLength);

            env.Run();
            Assert.IsTrue(get.IsTriggered);
            Assert.AreEqual(0, res.Count);
            Assert.AreEqual(0, res.PutQueueLength);
            Assert.AreEqual(0, res.GetQueueLength);
        }
Пример #8
0
        protected virtual bool DestroySignedCertificates(
            X509Certificate2Collection myCertificates, X509Certificate2Collection rootCertificates)
        {
            try
            {
                var certificateNames = new List <string>();
                if (MyStore != null)
                {
                    MyStore.RemoveRange(myCertificates);

                    IEnumerable <string> myCertNames = myCertificates.Cast <X509Certificate2>()
                                                       .Select(c => c.GetNameInfo(X509NameType.SimpleName, false));

                    certificateNames.AddRange(myCertNames);
                }

                if (RootStore != null)
                {
                    RootStore.RemoveRange(rootCertificates);

                    IEnumerable <string> rootCertNames = rootCertificates.Cast <X509Certificate2>()
                                                         .Select(c => c.GetNameInfo(X509NameType.SimpleName, false));

                    certificateNames.AddRange(rootCertNames);
                }

                foreach (string certificateName in certificateNames)
                {
                    if (_certificateCache.ContainsKey(certificateName))
                    {
                        _certificateCache.Remove(certificateName);
                    }
                }

                return(true);
            }
            catch (CryptographicException) { return(false); }
        }
Пример #9
0
        public void TestImmediateStore()
        {
            var env = new Environment();
              var res = new MyStore(env);
              Assert.AreEqual(0, res.Count);
              Assert.AreEqual(0, res.PutQueueLength);
              Assert.AreEqual(0, res.GetQueueLength);

              var put = res.Put(1);
              Assert.IsTrue(put.IsTriggered);
              Assert.AreEqual(1, res.Count);
              Assert.AreEqual(0, res.PutQueueLength);
              Assert.AreEqual(0, res.GetQueueLength);

              var get = res.Get();
              Assert.IsTrue(get.IsTriggered);
              Assert.AreEqual(0, res.Count);
              Assert.AreEqual(0, res.PutQueueLength);
              Assert.AreEqual(0, res.GetQueueLength);

              get = res.Get();
              Assert.IsFalse(get.IsTriggered);
              Assert.AreEqual(0, res.Count);
              Assert.AreEqual(0, res.PutQueueLength);
              Assert.AreEqual(1, res.GetQueueLength);

              put = res.Put(1);
              Assert.IsTrue(put.IsTriggered);
              Assert.AreEqual(1, res.Count);
              Assert.AreEqual(0, res.PutQueueLength);
              Assert.AreEqual(1, res.GetQueueLength);

              env.Run();
              Assert.IsTrue(get.IsTriggered);
              Assert.AreEqual(0, res.Count);
              Assert.AreEqual(0, res.PutQueueLength);
              Assert.AreEqual(0, res.GetQueueLength);
        }