コード例 #1
0
ファイル: Employees.cs プロジェクト: n-mitic/CraftedFood
 public static void ChangePassword(int empId, string password)
 {
     using (var dc = new DataClassesDataContext())
     {
         try
         {
             var emp = dc.Employees.First(x => x.EmployeeId == empId && x.IsActive);
             if (emp.IsActive)
             {
                 var hashedPass = HashPassword.SaltedHashPassword(password, emp.Email);
                 emp.Password = hashedPass;
                 dc.SubmitChanges();
             }
         }
         catch (Exception)
         {
             throw new Exception("Nije izmenjen");
         }
     }
 }
コード例 #2
0
 public static Data.DTOs.LoginDto CheckUsernameAndPassword(string email, string password)
 {
     using (DataClassesDataContext dc = new DataClassesDataContext())
     {
         var pass = HashPassword.SaltedHashPassword(password, email);
         var find = dc.Employees.Where(a => a.Email == email && a.Password == pass && a.IsActive == true)
                    .Include(a => a.Role.RolePermissions.Select(x => x.PermissionId))
                    .Select(a => new Data.DTOs.LoginDto()
         {
             Name        = a.Name,
             Email       = a.Email,
             Mobile      = a.Mobile,
             EmployeeId  = a.EmployeeId,
             RoleId      = (int)a.RoleId,
             Permissions = a.Role.RolePermissions.Select(x => x.PermissionId).ToList()
         });
         if (find.Any())
         {
             return(find.First());
         }
         return(null);
     }
 }