Exemple #1
0
 //分配和登录两个功能
 /// <summary>
 /// 根据用户名和密码来登录,并返回用户名的id
 /// </summary>
 /// <param name="mail"></param>
 /// <param name="pwd"></param>
 /// <param name="userId"></param>
 /// <returns>成功为true,失败为false,并且userId=-1</returns>
 public static bool Login(string mail, string pwd, out int userId)
 {
     using (var empSvc = new DAL.EmployeeService())
     {
         var emp = empSvc.GetAll(m => m.Email == mail && m.Password == pwd).FirstOrDefaultAsync();
         emp.Wait();
         if (emp.Result == null)
         {
             userId = -1;
             return(false);
         }
         else
         {
             userId = emp.Result.Id;
             return(true);
         }
     }
 }