Beispiel #1
0
        public static void SetSecurityAccess()
        {
            var dbMunicipalArchiveEntities = new dbMunicipalArchiveEntities();
            var result = dbMunicipalArchiveEntities.tblSecurityAccess.FirstOrDefault(x => x.Id == 1);

            if (result == null)
            {
                var tblSecurityAccess = new tblSecurityAccess
                {
                    Id      = 1,
                    Time    = PersianDateTime.Now.AddMinutes(-10).ToString(),
                    Counter = "0"
                };
                dbMunicipalArchiveEntities.tblSecurityAccess.Add(tblSecurityAccess);
                dbMunicipalArchiveEntities.SaveChanges();
            }
            else if (result.Time == null)
            {
                var tblSecurityAccess = new tblSecurityAccess
                {
                    Id   = 1,
                    Time = PersianDateTime.Now.AddMinutes(-10).ToString()
                };
                using (dbMunicipalArchiveEntities)
                {
                    dbMunicipalArchiveEntities.tblSecurityAccess.Attach(tblSecurityAccess);
                    dbMunicipalArchiveEntities.Entry(tblSecurityAccess).Property(x => x.Time).IsModified = true;
                    dbMunicipalArchiveEntities.SaveChanges();
                }
            }
        }
Beispiel #2
0
        public void StartSecurityTimeAccess()//taeen zaman vorod eshtebah
        {
            var tblSecurityAccess = new tblSecurityAccess
            {
                Id   = 1,
                Time = PersianDateTime.Now.ToString()
            };

            using (var dbMunicipalArchiveEntities = new dbMunicipalArchiveEntities())
            {
                dbMunicipalArchiveEntities.tblSecurityAccess.Attach(tblSecurityAccess);
                dbMunicipalArchiveEntities.Entry(tblSecurityAccess).Property(x => x.Time).IsModified = true;
                dbMunicipalArchiveEntities.SaveChanges();
            }
        }
Beispiel #3
0
        public static void SaveCounter(int num)//zakhire tedad mavared vorod eshtebah
        {
            var tblSecurityAccess = new tblSecurityAccess
            {
                Id      = 1,
                Counter = num.ToString()
            };

            using (var dbMunicipalArchiveEntities = new dbMunicipalArchiveEntities())
            {
                dbMunicipalArchiveEntities.tblSecurityAccess.Attach(tblSecurityAccess);
                dbMunicipalArchiveEntities.Entry(tblSecurityAccess).Property(x => x.Counter).IsModified = true;
                dbMunicipalArchiveEntities.SaveChanges();
            }
        }