コード例 #1
0
ファイル: UsersController.cs プロジェクト: monpham2310/PayBay
 public HttpResponseMessage PostLogin(Account account, string type)
 {
     JArray result = new JArray();
     JObject body = new JObject();      
     if (account != null)
     {                
         var uid = new SqlParameter("@Email", account.Email);
         var pwd = new SqlParameter("@Pass", account.Password);
         result = Methods.GetInstance().ExecQueryWithResult("viethung_paybayservice.sp_UserLogin", CommandType.StoredProcedure, ref Methods.err, uid, pwd);
         if (result.Count > 0)
         {
             body = result[0].ToObject<JObject>();
         }
         else
         {
             body = Methods.CustomResponseMessage(0, "Login isn't successful!");                    
             return Request.CreateResponse(HttpStatusCode.BadRequest, body);
         }                
     }
     return Request.CreateResponse(HttpStatusCode.OK, body);
 }
コード例 #2
0
ファイル: UsersController.cs プロジェクト: monpham2310/PayBay
 public async Task<HttpResponseMessage> ResetPassword(Account account,int code)
 {
     JObject result = new JObject();
     try
     {
         var email = new SqlParameter("@Email", account.Email);
         var pass = new SqlParameter("@Pass", account.Password);
         bool check = Methods.GetInstance().ExecNonQuery("viethung_paybayservice.sp_ResetPassword",CommandType.StoredProcedure,ref Methods.err, email, pass);
         if (check)
         {
             //TODO: send mail
             await Methods.GetInstance().SendMail(account.Email, account.Pwd);
             result = Methods.CustomResponseMessage(1, "Reset pass is successful!");                    
         }
         else
         {
             result = Methods.CustomResponseMessage(0, "Reset pass is NOT successful!");
         }
     }
     catch (Exception ex)
     {
         return Request.CreateResponse(HttpStatusCode.BadRequest, ex.Message);
     }
     return Request.CreateResponse(HttpStatusCode.OK, result);
 }