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(); } } }
public void ChangePassword() { var tblUser = new tblUser { Id = 1, UserName = DUserName, UserPassword = BCrypt.Net.BCrypt.HashPassword(DPassword) }; using (var dbMunicipalArchiveEntities = new dbMunicipalArchiveEntities()) { dbMunicipalArchiveEntities.tblUser.Attach(tblUser); dbMunicipalArchiveEntities.Entry(tblUser).Property(x => x.UserName).IsModified = true; dbMunicipalArchiveEntities.Entry(tblUser).Property(x => x.UserPassword).IsModified = true; dbMunicipalArchiveEntities.SaveChanges(); } }
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(); } }
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(); } }