コード例 #1
0
ファイル: Password.cs プロジェクト: tayyebi/Sigma1
 public int Change(string Value, int UserId)
 {
     using (var db = new ADONET.MainModel())
     {
         var p = new PasswordSet {
             Value = Value, UserId = UserId
         };
         db.PasswordSet.Add(p);
         db.SaveChanges();
         return(p.Id);
     }
 }
コード例 #2
0
        public void ChangeIoTDevicePassword(string deviceId, PasswordSet passwordSet)
        {
            DBHelper._IoTDevice dbhelp    = new DBHelper._IoTDevice();
            IoTDevice           iotDevice = dbhelp.GetByid(deviceId);

            if (iotDevice == null)
            {
                throw new Exception("404");
            }

            if (Crypto.VerifyHashedPassword(iotDevice.IoTHubDevicePW, passwordSet.OldPassword))
            {
                iotDevice.IoTHubDevicePW = Crypto.HashPassword(passwordSet.NewPassword);
                dbhelp.Update(iotDevice);
            }
            else
            {
                throw new Exception("401");
            }
        }