public ActionResult CheckEmail(CheckEmailModel checkEmail)
 {
     Console.WriteLine("check user email");
     using (SqlConnection sqlConnection = new SqlConnection(Global.connect_string))
     {
         sqlConnection.Open();
         string strIdExist = @"SELECT Id FROM Group_User Where Id = @notifyId";
         using (SqlCommand cmd = new SqlCommand(strIdExist, sqlConnection))
         {
             cmd.Parameters.AddWithValue("@notifyId", checkEmail.NotifyId);
             using (SqlDataReader reader = cmd.ExecuteReader())
             {
                 if (!reader.HasRows && !reader.Read())
                 {
                     return(CreatedAtAction("CheckEmail", new { errorcode = 401, msg = "can't find notifyId" }));
                 }
             }
         }
         string strCheck = @"IF (SELECT Accepted FROM Group_User Where Id = @notifyId)=2 
                             BEGIN
                                 Update Group_User SET Accepted = 1 Where Id = @notifyId
                             END
                             ELSE IF (SELECT Accepted FROM Group_User Where Id = @notifyId)=3
                             BEGIN
                                 DELETE From Group_User WHERE Id = @notifyId
                             END ";
         using (SqlCommand cmd = new SqlCommand(strCheck, sqlConnection))
         {
             cmd.Parameters.AddWithValue("@notifyId", checkEmail.NotifyId);
             cmd.ExecuteNonQuery();
             return(CreatedAtAction("CheckEmail", new { errorcode = -1, msg = "success check email" }));
         }
     }
 }
예제 #2
0
        public IHttpActionResult CheckEmailExists(CheckEmailModel checkEmailModel)
        {
            try
            {
                if (_accountAppService.CheckIfEmailExists(checkEmailModel.Email))
                {
                    return(BadRequest("Email already taken"));
                }

                return(Ok());
            }
            catch (Exception ex)
            {
                return(BadRequest(ex.Message));
            }
        }